Linking cURL in C++ - c++

After trying this for all of today with no result, and searching through LOTS of threads on here and on forums, I'm hoping someone here will be able to find a solution.
I'm trying to get this simple example using cURL to work on Windows using MinGW.
When I try to compile it with g++
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
it always gives me the same errors:
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x87): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xb6): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xc2): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xd9): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x101): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
To be honest, I'm all out of ideas what could be causing this. Any help would be greatly appreciated. Thanks in advance!
Edit:
When adding the parameter -v, I'm getting the following output:
g++ -v -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/cc1plus.exe -quiet -v -I curl\include
-iprefix c:\mingw\bin\../lib/gcc/mingw32/4.7.0/ -D CURL_STATICLIB Test.cpp -quiet -dumpbase Test.cpp -mtune=i386 -march=i386 -auxbase Test -version -o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
curl\include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include-fixed
End of search list.
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9fc40f37d31a03e5502141ce58bdf4c7
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe -o C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/collect2.exe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o Test.exe c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o -Lcurl\lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../.. C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o -lcurl -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32
-luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0xf): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x36): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x42): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x59): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x81): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
I still don't know what could be causing my problem though...are all those "ignored" directories normal?
Edit: After now using a 32-bit cURL library, the compiler is literally spamming error messages. I don't know if it means it's working or even more broken now... Had to remove a few messages, as they were 506 lines...
>g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
curl\lib/libcurl.a(easy.o):(.text+0x16): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(easy.o):(.text+0x39): undefined reference to `_WSACleanup#0'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x1662): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1688): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16cb): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16f7): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1723): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x174f): more undefined references to `_BN_num_bits' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1833): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1876): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18a2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18ce): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18fa): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x192a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x195a): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x199a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19c6): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19f2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a22): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a52): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ade): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b22): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b66): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1baa): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1bee): more undefined references to `_BN_bn2bin' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1e8c): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ea0): undefined reference to `_X509_get_subject_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eca): undefined reference to `_X509_NAME_get_index_by_NID'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ee2): undefined reference to `_X509_NAME_get_entry'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eea): undefined reference to `_X509_NAME_ENTRY_get_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x1efc): undefined reference to `_ASN1_STRING_type'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f15): undefined reference to `_ASN1_STRING_to_UTF8'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f7f): undefined reference to `_CRYPTO_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f96): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x203f): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2052): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x20e0): undefined reference to `_PEM_read_X509'
curl\lib/libcurl.a(ssluse.o):(.text+0x2105): undefined reference to `_X509_check_issued'
curl\lib/libcurl.a(ssluse.o):(.text+0x213e): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2146): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x21c6): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2274): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2280): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x22b4): more undefined references to `_X509_free' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x22c3): undefined reference to `_SSL_get_verify_result'
curl\lib/libcurl.a(ssluse.o):(.text+0x233e): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x23b7): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x23dc): undefined reference to `_CRYPTO_malloc'
curl\lib/libcurl.a(ssluse.o):(.text+0x23ec): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2467): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x248e): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x24c9): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x251a): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x251f): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x256a): undefined reference to `_RAND_add'
curl\lib/libcurl.a(ssluse.o):(.text+0x2578): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x2599): undefined reference to `_RAND_file_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b2): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b7): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x267f): undefined reference to `_ERR_clear_error'
curl\lib/libcurl.a(ssluse.o):(.text+0x268a): undefined reference to `_SSL_connect'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x3ecb): undefined reference to `_RAND_bytes'
curl\lib/libcurl.a(ftp.o):(.text+0xdac): undefined reference to `_bind#12'
curl\lib/libcurl.a(ftp.o):(.text+0xdbc): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xdfc): undefined reference to `_htons#4'
curl\lib/libcurl.a(ftp.o):(.text+0xe4f): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xe5f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xf2d): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xf51): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xfb4): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xfc4): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x10d1): undefined reference to `_listen#8'
curl\lib/libcurl.a(ftp.o):(.text+0x10dd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x11e9): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1249): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1429): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0x1478): undefined reference to `_accept#12'
curl\lib/libcurl.a(ftp.o):(.text+0x2bb9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0x3fc): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(telnet.o):(.text+0x432): undefined reference to `_WSACleanup#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe1b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe41): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xf11): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x17b): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x18b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3bb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3cb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5bd): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5d2): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ae): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ba): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x708): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x714): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x853): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x85f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9ad): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9b9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ldap.o):(.text+0x221): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x267): undefined reference to `__imp__ldap_msgfree'
curl\lib/libcurl.a(ldap.o):(.text+0x298): undefined reference to `__imp__ldap_unbind_s'
curl\lib/libcurl.a(ldap.o):(.text+0x6cb): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x721): undefined reference to `__imp__ldap_simple_bind_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x778): undefined reference to `__imp__ldap_search_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x796): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x825): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x888): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x8a3): undefined reference to `__imp__ldap_initA'
curl\lib/libcurl.a(ldap.o):(.text+0x8dd): undefined reference to `__imp__ldap_first_entry'
curl\lib/libcurl.a(ldap.o):(.text+0x91e): undefined reference to `__imp__ldap_get_dnA'
curl\lib/libcurl.a(ldap.o):(.text+0x9bd): undefined reference to `__imp__ldap_first_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0x9e9): undefined reference to `__imp__ldap_get_values_lenA'
curl\lib/libcurl.a(ldap.o):(.text+0xbc9): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xc1e): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc3d): undefined reference to `__imp__ldap_next_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc56): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc71): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(ldap.o):(.text+0xc86): undefined reference to `__imp__ldap_next_entry'
curl\lib/libcurl.a(ldap.o):(.text+0xcaf): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xcbc): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xccb): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xcea): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(tftp.o):(.text+0x210): undefined reference to `_sendto#24'
curl\lib/libcurl.a(tftp.o):(.text+0x29b): undefined reference to `_sendto#24'
[...]
curl\lib/libcurl.a(ssh.o):(.text+0x46a9): undefined reference to `_libssh2_knownhost_init'
curl\lib/libcurl.a(ssh.o):(.text+0x46cd): undefined reference to `_libssh2_knownhost_readfile'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24): undefined reference to `_RTMP_Close'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x2c): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xbc): undefined reference to `_setsockopt#20'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xcf): undefined reference to `_RTMP_Connect1'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x13d): undefined reference to `_RTMP_Write'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x15e): undefined reference to `_RTMP_Alloc'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x16c): undefined reference to `_RTMP_Init'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x17c): undefined reference to `_RTMP_SetBufferMS'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x190): undefined reference to `_RTMP_SetupURL'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1ac): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1eb): undefined reference to `_RTMP_Read'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24e): undefined reference to `_RTMP_ConnectStream'
curl\lib/libcurl.a(select.o):(.text+0x2e): undefined reference to `_WSASetLastError#4'
curl\lib/libcurl.a(select.o):(.text+0x2ae): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x2bd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x354): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x374): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3b4): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3d1): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x42f): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x445): more undefined references to `___WSAFDIsSet#8' follow
curl\lib/libcurl.a(select.o):(.text+0x77d): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x78c): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x849): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x863): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x884): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(content_encoding.o):(.text+0x170): undefined reference to `_inflate'
curl\lib/libcurl.a(content_encoding.o):(.text+0x18c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x1ac): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x224): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x27e): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x294): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2be): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2ce): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x33e): undefined reference to `_inflateInit_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x472): undefined reference to `_zlibVersion'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4b0): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4f8): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x58c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x5c9): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x6ca): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(nonblock.o):(.text+0x2a): undefined reference to `_ioctlsocket#12'
curl\lib/libcurl.a(md5.o):(.text+0x15): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.text+0x3b): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.text+0x4e): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x0): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x4): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x8): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x14): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x18): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x1c): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(curl_gethostname.o):(.text+0x19): undefined reference to `_gethostname#8'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x2e4): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x427): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x811): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xc5c): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xd7e): undefined reference to `_ntohs#4'
collect2.exe: error: ld returned 1 exit status
Edit: I also tried downloading the Windows OpenSSL package offered on their website and including it - no change.
Edit: It's finally working! The solution was to use the 32-bit cURL package and to pass these parameters to the compiler:
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurldll -lssh2 -lidn -lrtmp -lssl -lcrypto -lz -lws2_32 -lwldap32

Since everything is setup correctly, I see two solutions:
either remove -DCURL_STATICLIB or add -static to your command line.
Edit:
It took some time, but it looks like you have a 32 bit Mingw and a 64 bit libcurl. Download the 32 bit libcurl and try again.

Related

vulkan build undefined reference to `vkEnumerateInstanceExtensionProperties#12'

so i was trying to set up vulkan on vscode in windows.
and i strugle to fix the link errors.
at first i had problems with GLFM
but it looks like i sorted it out, by compiling it with mingw myself.
but now i guess the following link error
undefined reference to `vkEnumerateInstanceExtensionProperties#12'
how should i resolve that issue?
my makefile looks like that at the moment:
DIR1 := external/GLFM/include
DIR2 := external/glm/
DIR3 := external/vulkan/Include
INC=$(DIR1) $(DIR2) $(DIR3)
INC_PARAMS=$(foreach d, $(INC), -I$d)
LDPATHS2 := -Lexternal/GLFM/Lib/ -Lexternal/vulkan/Lib/
LDLIBS = -lglfw3 -lvulkan-1 -lgdi32
VulkanTest: main.cpp
g++ $(CFLAGS) $(INC_PARAMS) $(LDPATHS2) -o VulkanTest main.cpp $(LDLIBS)
EDIT:
i have added the -lgdi32 as that seemed to get rid of all of those
link errors:
C:\Users\Michael\AppData\Local\Temp\ccRgsVDp.o:main.cpp:(.text.startup+0x7c): undefined reference to `vkEnumerateInstanceExtensionProperties#12'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x12b): undefined reference to `_imp__CreateDCW#16'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x166): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x181): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1d4): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x257): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x29f): undefined reference to `_imp__DeleteDC#4'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xa49): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xa64): undefined reference to `_imp__GetDeviceCaps#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf06): undefined reference to `_imp__CreateDCW#16'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf23): undefined reference to `_imp__GetDeviceGammaRamp#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xf33): undefined reference to `_imp__DeleteDC#4'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x107b): undefined reference to `_imp__CreateDCW#16'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x1098): undefined reference to `_imp__SetDeviceGammaRamp#8'
external/GLFM/Lib/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x10a8): undefined reference to `_imp__DeleteDC#4'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1f5): undefined reference to `_imp__CreateDIBSection#24'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x268): undefined reference to `_imp__CreateBitmap#20'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x295): undefined reference to `_imp__DeleteObject#4'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x387): undefined reference to `_imp__DeleteObject#4'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x397): undefined reference to `_imp__DeleteObject#4'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xbe1): undefined reference to `_imp__CreateRectRgn#16'
external/GLFM/Lib/libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xc41): undefined reference to `_imp__DeleteObject#4'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x6c4): undefined reference to `_imp__DescribePixelFormat#16'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xbbf): undefined reference to `_imp__DescribePixelFormat#16'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xf4a): undefined reference to `_imp__SwapBuffers#4'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x126e): undefined reference to `_imp__ChoosePixelFormat#8'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x128b): undefined reference to `_imp__SetPixelFormat#12'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x15b4): undefined reference to `_imp__DescribePixelFormat#16'
external/GLFM/Lib/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x15fd): undefined reference to `_imp__SetPixelFormat#12'

Can't compile qt project with static lib curl

I am trying to compile a qt project with qtcurl using a statically built curl.
I am using the following to build a minimalist curl static library:
./configure --disable-shared --enable-static --prefix=/tmp/curl --disable-ldap --disable-sspi --without-librtmp --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb --without-libidn --enable-ares
I am including
-L/tmp/curl/lib/libcurl.a
in the LIBS of the project, and
/tmp/curl/include
in the INCLUDEPATH
This is the output that I am getting:
QtCUrl.o: In function `QtCUrl::QtCUrl()':
QtCUrl.cpp:(.text+0x10d): undefined reference to `curl_easy_init'
QtCUrl.o: In function `QtCUrl::~QtCUrl()':
QtCUrl.cpp:(.text+0x32e): undefined reference to `curl_slist_free_all'
QtCUrl.cpp:(.text+0x355): undefined reference to `curl_easy_cleanup'
QtCUrl.o: In function `QtCUrl::setOptions(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0xcee): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xdac): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xee9): undefined reference to `curl_slist_append'
QtCUrl.cpp:(.text+0xfe5): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1078): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x109f): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1155): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1290): undefined reference to `curl_easy_setopt'
QtCUrl.o: In function `QtCUrl::exec(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0x1f27): undefined reference to `curl_easy_perform'
QtCUrl.o: In function `curlGlobalInit()':
QtCUrl.cpp:(.text+0xa6): undefined reference to `curl_global_init'
collect2: error: ld returned 1 exit status
What am I missing here?

Linker error on GLFW on linux (x11)

I just installed GLFW3 on Ubuntu and I'm testing the example code from the documentation (http://www.glfw.org/documentation.html) and I got those errors.
I tried multiples thing like adding -ldl, but nothing seems to work.
Here is the error log (GCC):
g++ -o bin/Debug/Game obj/Debug/main.o -ldl -lglfw3 -lm -lGL -lGLU
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `_glfwInitVulkan':
vulkan.c:(.text+0x42): undefined reference to `dlopen'
vulkan.c:(.text+0xa9): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `_glfwTerminateVulkan':
vulkan.c:(.text+0x382): undefined reference to `dlclose'
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `glfwGetInstanceProcAddress':
vulkan.c:(.text+0x72f): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `translateKeyCode':
x11_init.c:(.text+0x6a): undefined reference to `XkbKeycodeToKeysym'
x11_init.c:(.text+0x14a): undefined reference to `XkbKeycodeToKeysym'
x11_init.c:(.text+0x177): undefined reference to `XGetKeyboardMapping'
x11_init.c:(.text+0x191): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `createKeyTables':
x11_init.c:(.text+0xc3e): undefined reference to `XkbGetMap'
x11_init.c:(.text+0xc61): undefined reference to `XkbGetNames'
x11_init.c:(.text+0x137f): undefined reference to `XkbFreeNames'
x11_init.c:(.text+0x1395): undefined reference to `XkbFreeKeyboard'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `hasUsableInputMethodStyle':
x11_init.c:(.text+0x14b2): undefined reference to `XGetIMValues'
x11_init.c:(.text+0x150c): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `getSupportedAtom':
x11_init.c:(.text+0x155b): undefined reference to `XInternAtom'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `detectEWMH':
x11_init.c:(.text+0x15ea): undefined reference to `XInternAtom'
x11_init.c:(.text+0x1610): undefined reference to `XInternAtom'
x11_init.c:(.text+0x1678): undefined reference to `XFree'
x11_init.c:(.text+0x16a1): undefined reference to `XFree'
x11_init.c:(.text+0x16ad): undefined reference to `XFree'
x11_init.c:(.text+0x16be): undefined reference to `XFree'
x11_init.c:(.text+0x16ca): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o):x11_init.c:(.text+0x190d): more undefined references to `XFree' follow
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x194e): undefined reference to `dlopen'
x11_init.c:(.text+0x1993): undefined reference to `dlsym'
x11_init.c:(.text+0x19c1): undefined reference to `dlsym'
x11_init.c:(.text+0x19ef): undefined reference to `dlsym'
x11_init.c:(.text+0x1a1d): undefined reference to `dlsym'
x11_init.c:(.text+0x1a8b): undefined reference to `dlopen'
x11_init.c:(.text+0x1ad0): undefined reference to `dlsym'
x11_init.c:(.text+0x1afe): undefined reference to `dlsym'
x11_init.c:(.text+0x1b56): undefined reference to `XQueryExtension'
x11_init.c:(.text+0x1bdf): undefined reference to `dlopen'
x11_init.c:(.text+0x1c24): undefined reference to `dlsym'
x11_init.c:(.text+0x1c52): undefined reference to `dlsym'
x11_init.c:(.text+0x1c80): undefined reference to `dlsym'
x11_init.c:(.text+0x1cae): undefined reference to `dlsym'
x11_init.c:(.text+0x1cdc): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(x11_init.c.o):x11_init.c:(.text+0x1d0a): more undefined references to `dlsym' follow
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x214a): undefined reference to `dlopen'
x11_init.c:(.text+0x218f): undefined reference to `dlsym'
x11_init.c:(.text+0x21bd): undefined reference to `dlsym'
x11_init.c:(.text+0x21eb): undefined reference to `dlsym'
x11_init.c:(.text+0x220d): undefined reference to `dlopen'
x11_init.c:(.text+0x2252): undefined reference to `dlsym'
x11_init.c:(.text+0x2280): undefined reference to `dlsym'
x11_init.c:(.text+0x22ae): undefined reference to `dlsym'
x11_init.c:(.text+0x23b4): undefined reference to `XkbQueryExtension'
x11_init.c:(.text+0x23f3): undefined reference to `XkbSetDetectableAutoRepeat'
x11_init.c:(.text+0x2420): undefined reference to `dlopen'
Order of libraries matter. If library A depends on library B, then A must come before B on the command line.
In your case, since the glfw3 library depends on the dl library, you must switch order so that glfw3 comes before dl on the command line.
You also must link with the X11 library.
So the full command line should look something like
g++ -o bin/Debug/Game obj/Debug/main.o -lglfw3 -ldl -lm -lGL -lGLU -lX11

GLFW3 - Undefined reference to XRR

I am trying to compile a very simple OpenGL program that uses GLFW3. Despite linking everything I deem necessary, I'm getting a plethora of undefined references.
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwInitGammaRamp':
x11_gamma.c:(.text+0x49): undefined reference to `XRRGetScreenResources'
x11_gamma.c:(.text+0x6a): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0x81): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformGetGammaRamp':
x11_gamma.c:(.text+0xce): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0xf1): undefined reference to `XRRGetCrtcGamma'
x11_gamma.c:(.text+0x198): undefined reference to `XRRFreeGamma'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformSetGammaRamp':
x11_gamma.c:(.text+0x24c): undefined reference to `XRRAllocGamma'
x11_gamma.c:(.text+0x303): undefined reference to `XRRSetCrtcGamma'
x11_gamma.c:(.text+0x30f): undefined reference to `XRRFreeGamma'
/usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x1a67): undefined reference to `XRRQueryExtension'
x11_init.c:(.text+0x1a91): undefined reference to `XRRQueryVersion'
x11_init.c:(.text+0x1b25): undefined reference to `XIQueryVersion'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwSetVideoMode':
x11_monitor.c:(.text+0x177): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x19c): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x1be): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x3d0): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x3dc): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x3e8): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x3f4): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwRestoreVideoMode':
x11_monitor.c:(.text+0x446): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x46b): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x4e0): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x4ec): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x4f8): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitors':
x11_monitor.c:(.text+0x55a): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x577): undefined reference to `XRRGetOutputPrimary'
x11_monitor.c:(.text+0x5cf): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x5ea): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x659): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x676): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x682): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x703): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x70f): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x733): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitorPos':
x11_monitor.c:(.text+0x8a2): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x8c7): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x8ff): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x90b): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoModes':
x11_monitor.c:(.text+0x9ad): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x9cf): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0xb44): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0xb50): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoMode':
x11_monitor.c:(.text+0xc28): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0xc4d): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0xca2): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0xcae): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `createWindow':
x11_window.c:(.text+0x666): undefined reference to `XISelectEvents'
x11_window.c:(.text+0x6a8): undefined reference to `XRRSelectInput'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `processEvent':
x11_window.c:(.text+0x1711): undefined reference to `XRRUpdateConfiguration'
My linked CMake flags:
-I/usr/local/include -L/usr/local/lib -lglfw3 -lGLU -lGL -lGLEW
Should I be linking anything else?
I figured out the answer myself while writing the question.
I was misled into believing that I was linking everything necessary because of the output of
pkg-config --libs --cflags --print-requires glfw3
which was
-I/usr/local/include -L/usr/local/lib -lglfw3
The --print-requires flag was having no impact at all on the output, which seemed odd. I searched and printed the corresponding .pc file.
sudo find / | grep "glfw3\.pc"
cat /usr/local/lib/pkgconfig/glfw3.pc
There I found this.
Requires.private: x11 xrandr xi xxf86vm gl
Which indicates which libraries are required for static linking. I added their correponding flags to CMake and it worked. My mistake was that I missed the --print-requires-private flag when executing pkg-config.
I hope this helps someone save some time.

How to use static linking with OpenSSL in C/C++

I wrote simple apps with Openssl in C and C++. I compile them like this:
gcc openssltest.c -o openssltest -lcrypto
g++ openssltest.cpp -o openssltest -lcrypto
And its all ok but only, when you have Openssl installed.
I would like to compile it that I can run them on OS where theres no Openssl installend (linux-like OS). I tried this:
gcc -c openssltest.c -lcrypto -static
gcc openssltest.o -o openssltest -lcrypto -static
and same for C++:
g++ -c openssltest.cpp -lcrypto -static
g++ openssltest.o -o openssltest -lcrypto -static
But have those errors:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x2c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x37): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x354): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x3fb): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x474): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x52e): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x5a2): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x60b): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x638): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x6cd): undefined reference to `dladdr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x731): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x78a): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x342): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5d7): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x659): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x893): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x90d): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x97c): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xa6f): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xaec): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb7e): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
How can I make this? I remember that a while ago I did this but now, erm, forgot how to do it. Im on Ubuntu 13.04 x64 - can it be an issue?
I had a similar issue trying to statically compile a simple DES program using the openssl lib. I used -lcrypto -lz -ldl -static-libgcc and it worked for me. No warnings or errors.
You need to be aware that libraries need to availiable as statically linked *.a files. If they are not, then compilation will either fail or you end up with a dynamically linked executable.
If this gets too much PITA (all the libraries dependencies need to be statically compiled to, and their deps too and so on) use something like buildroot
A hotfix: try to link in libdl statically, too.
If this not works, IMHO your libcrypto.a is bad compiled.
I had the same problem as you. Here's the command that solved it for me:
gcc yourfile.c -o yourfile -static -lcrypto -lz -ldl
It generates this warning:
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': (.text+0x1b): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
but the executable still works.