cURL / Mailing Lists / curl-library / Single Mail


Re: Linker errors in pre-compiled static library for windows

From: Garrick Mason <>
Date: Sat, 24 Aug 2013 22:06:38 -0400

On 8/22/2013 6:33 AM, Gisle Vanem wrote:
> Try adding 'libidn.a' and '-lws2_32' to the link command.
> libidn.a should be in the .zip Gunter has provided.
> You may have to add some more libs depending on what
> features is built into that static libcurl.a.
I took another look at the build.txt file and found this line:
curl 7.32.0 (i386-pc-win32) libcurl/7.32.0 OpenSSL/1.0.0k zlib/1.2.8
libidn/1.18 libssh2/1.4.3 librtmp/2.3
which I'm assuming is the list of libraries that are being utilized. I
download the static libraries for openSSL, there are two .a files in the
lib/MinGW directory (libeay32.a & ssleay32.a) and I pointed the linker
towards both of them. I couldn't find any pre-compiled static libraries
for version 1.2.8 of zlib, so I downloaded the source and compiled it
myself (at least I think it worked, I got the file libzlibstatic.a after
compiling it in CodeBlocks) and pointed the linker towards the zlib
library. I then included the other curl libraries that came with the
package. I also added '-lws2_32' to the linker arguments and I made g++
generate a map, but the command I added was '-Wl,' since the
other one didn't work.

The map generates just fine, but I'm still getting mostly the same
"undefined reference" errors, although the file url.o doesn't show up
anymore in the build log, just easy.o, select.o, asyn-thread.o, sendf.o,
and connect.o. Here are the full commands from CodeBlocks' build log:
mingw32-g++.exe -Wall -fexceptions -g -DCURL_STATICLIB
-I"C:\Users\G\Desktop\selection\Win32 -
Generic\libcurl\curl-7.32.0-devel-mingw32\include" -c
C:\Users\G\Desktop\RandomEp\main.cpp -o obj\Debug\main.o
C:\Users\G\Desktop\RandomEp\main.cpp: In function 'int main()':
C:\Users\G\Desktop\RandomEp\main.cpp:6:14: warning: unused variable
'hand' [-Wunused-variable]
mingw32-g++.exe -o bin\Debug\RandomEp.exe obj\Debug\main.o -lws2_32
-Wl, "C:\Users\G\Desktop\selection\Win32 -
C:\OpenSSL\lib\MinGW\libeay32.a C:\OpenSSL\lib\MinGW\ssleay32.a
C:\zlib\zlib-1.2.8\libzlibstatic.a "C:\Users\G\Desktop\selection\Win32 -
"C:\Users\G\Desktop\selection\Win32 -
"C:\Users\G\Desktop\selection\Win32 -

I deleted the -L parameter pointing to the lib directory in the package
because I saw from the map that including the directory itself made no
difference, the map only changes when I specify the exact .a files,
which I fail to understand; plus, I tried compiling the program when the
flag and all the different libraries were present and I still received
the same errors.

I've gathered from some google searching that most of the errors are
related to the winsock library. The only suggestions I've seen have been
to point the linker to one of two libraries, either libws2_32.a or
libwsock32.a. I've tried including both libraries (individually of
course) explicitly as well as through the arguments -libws2_32 and
-libwsock. Both files showed up in the map in one line similar to the
LOAD C:\MinGW\lib\libws2_32.a
But including these libraries has not stopped the linker errors

The only suspicious thing I've been able to find is that in the curl
source code, specifically in easy.c on line 169, a comment indicates
that curl looks for the file "winsock.dll". I did a search (it was a
recursive search, so it also scanned system32 and all other folders)
from the directory C:\Windows for the file and the only thing that came
up was "winsockhc.dll". Apart from this discrepancy, I'm completely stumped.
List admin:
Received on 2013-08-25