【问题标题】:undefined reference c++ mingw32 [duplicate]未定义的参考c ++ mingw32 [重复]
【发布时间】:2016-04-23 20:47:18
【问题描述】:

我在C++ 中制作了一个使用wsock32openssl 的TCP 套接字程序,但我想链接openssl 静态。

我已经在 mingw32 上使用 shared 和 no-shared 编译了 openssl,但我不断收到相同的未定义引用错误。

如果我链接.a.dll 而不是.a,它构建得很好,但我不想使用 dll。

这是我的编译方式:

/c/MinGW/bin/mingw32-g++.exe main.cpp -I /c/Mingw-builds/openssl/include -L/c/MinGW/lib -L /c/Mingw-builds/openssl/lib -std=c++11 -lwsock32 -lshlwapi -lws2_32 -lssl -lcrypto -lgdi32

我得到的错误:

C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0xac): undefined reference to `getnameinfo@28'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0x6ef): undefined reference to `freeaddrinfo@4'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0xa28): undefined reference to `getaddrinfo@16'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0xe6): undefined reference to `WSAGetLastError@0'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x2d6): undefined reference to `WSAGetLastError@0'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x40b): undefined reference to `getsockopt@20'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x43b): undefined reference to `gethostbyname@4'
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x4a0): undefined reference to `WSAGetLastError@0'

【问题讨论】:

    标签: c++ c++11 gcc mingw32


    【解决方案1】:

    Nvm 通过正确订购使其工作:

    /c/MinGW/bin/mingw32-g++.exe main.cpp -o asdf.o -I /c/Mingw-builds/openssl/include -L /c/Mingw-builds/openssl/lib -std=c++11 -lmingw32 -lssl -lcrypto -luser32 -lgdi32 -lws2_32 -lwsock32 -lshlwapi -static-libgcc -static-libstdc++ -shared
    
    猜你喜欢
    • 2012-11-22
    • 2013-02-13
    • 2011-12-13
    • 2011-09-11
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多