0
votes

This question has already been asked, but no answers. I am trying to link statically libcurl on Windows with GNU GCC compiler (using last curl version 7.51) I have added ws2_32.a and libcurl.a to the linked libraries with the option -static and in search directories I have included curl\include and the /lib. And I added CURL_STATICLIB in defines.

Build Log:

mingw32-g++.exe -Wall -fexceptions -g -std=c++11 -DCURL_STATICLIB -IC:\Libcurl\static_built\include -IC:\c++\Tutorials\.cbp\libCurl -c C:\c++\Tutorials\.cbp\libCurl\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LC:\Libcurl\static_built\lib -o bin\Debug\libCurl\.exe.exe obj\Debug\main.o  -static  C:\Libcurl\static_built\lib\libcurl.a C:\MinGW\lib\libws2_32.a
C:\Libcurl\static_built\lib\libcurl.a(libcurl_la-formdata.o):formdata.c:(.text+0x491): undefined reference to `__mingw_basename'
collect2.exe: error: ld returned 1 exit status

Particularly the error:

undefined reference to `__mingw_basename'
1
I need to link any other library?Andy
"libgen" perpaps? -lgen on the command line?Daniel Stenberg
I included #include <libgen.h> but still undefined reference to `__mingw_basename'Andy
You need to link with the correct lib, just #including the right header isn't enoughDaniel Stenberg
I found libgenerate.dll.a which is located at C:\MinGW\msys\1.0\lib\perl5\vendor_perl\5.8\msys\auto\B\Generate. After linking it it pops up the same error, wich seem to me that I have linked another library. Where can I find it, if it is not that one?Andy

1 Answers

0
votes

You need to link libmingwex.a in order to solve the problem: undefined reference to __mingw_basename'. This library is located at MinGW/libs.