c++ - cURL link error with MinGW-w64 GCC on MSYS2 -


i using msys2, , mingw-w64 originated libraries , toolchains (from pacman repository 'mingw32') via mingw32_shell.bat environment.

i use mingw32/mingw-w64-i686-gcc package; mingw32 packaged path prefixed /mingw32, gcc binary /mingw32/gcc, example.

what in trouble is, linking curl libraries g++. installed mingw32/mingw-w64-i686-curl. provides /mingw32/include/curl/curl.h, /mingw32/lib/libcurl.a, /mingw32/lib/libcurl.dll.a, , on. while package not provide curl.pc, -lcurl not work. run:

$ curl-config --cflags -i/mingw32/include $ curl-config --libs -l/mingw32/lib -lcurl -lidn -lrtmp -lssh2 -lssl -lcrypto -lgdi32 -lssl -lcrypto -lwldap32 -lz -lws2_32 $ curl-config --static-libs /mingw32/lib/libcurl.a -lc:/msys64/mingw32/lib -pipe -lc:/msys64/mingw32/lib -lidn -lrtmp -lssh2 -lssl -lcrypto -lgdi32 -lssl -lcrypto -lwldap32 -lz -lws2_32 

good. added -i/mingw32/include cxxflags in makefile, , added /mingw32/lib/libcurl.dll.a g++ arguments in executable linking target in makefile. (the cxxflags contains -std=c++11 -fopenmp -o2 -g -i..)

it failed.

main.o: in function `query': c:\users\administrator\ngd\5/main.cc:80: undefined reference `_imp__curl_easy_init' main.o: in function `urlencode': c:\users\administrator\ngd\5/main.cc:34: undefined reference `_imp__curl_free' c:\users\administrator\ngd\5/main.cc:29: undefined reference `_imp__curl_easy_escape' c:\users\administrator\ngd\5/main.cc:30: undefined reference `_imp__curl_easy_escape' main.o: in function `query': c:\users\administrator\ngd\5/main.cc:88: undefined reference `_imp__curl_easy_setopt' c:\users\administrator\ngd\5/main.cc:93: undefined reference `_imp__curl_easy_perform' c:\users\administrator\ngd\5/main.cc:94: undefined reference `_imp__curl_easy_cleanup' collect2.exe: error: ld returned 1 exit status 

(main.o main.cc, includes curl/curl.h , curl function usages.)

i added -dcurl_staticlibs -i/mingw32/include cxxflags instead, , /mingw32/lib/libcurl.a g++ arguments executable.

failed again.

main.o: in function `query': c:\users\administrator\ngd\5/main.cc:80: undefined reference `curl_easy_init' main.o: in function `urlencode': c:\users\administrator\ngd\5/main.cc:34: undefined reference `curl_free' c:\users\administrator\ngd\5/main.cc:35: undefined reference `curl_free' c:\users\administrator\ngd\5/main.cc:29: undefined reference `curl_easy_escape' c:\users\administrator\ngd\5/main.cc:30: undefined reference `curl_easy_escape' main.o: in function `query': c:\users\administrator\ngd\5/main.cc:88: undefined reference `curl_easy_setopt' c:\users\administrator\ngd\5/main.cc:90: undefined reference `curl_easy_setopt' c:\users\administrator\ngd\5/main.cc:91: undefined reference `curl_easy_setopt' c:\users\administrator\ngd\5/main.cc:93: undefined reference `curl_easy_perform' c:\users\administrator\ngd\5/main.cc:94: undefined reference `curl_easy_cleanup' collect2.exe: error: ld returned 1 exit status 

what did examine:

$ nm /mingw32/lib/libcurl.a ... (other files) libcurl_la-escape.o: ... 00000340 t _curl_free ... (end of libcurl_la-escape.o) ... (other files)  $ nm /mingw32/lib/libcurl.dll.a ... (other files) d000018.o: ... 00000000 __imp__curl_free 00000000 t _curl_free ... (end of d000018.o) ... (other files) 

so problem (i think) __imp__curl_free or _curl_free defined, while compiler requires _imp__curl_free or curl_free.

any solution please?


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -