2016-04-23 14 views
0

Ich habe ein TCP-Socket-Programm in C++, die wsock32 und openssl verwendet, aber ich möchte openssl statische verbinden.undefined Referenz C++ Mingw32

Ich habe openssl auf mingw32 mit geteilten und no-shared kompiliert, aber ich bekomme immer die gleichen undefinierten Referenzfehler.

Es baut gut, wenn ich die .a.dll anstelle von .a verknüpfen, aber ich möchte keine DLLs verwenden.

Hier ist, wie ich kompilieren:

/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 

Fehler, die ich erhalten:

C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0xac): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0x6ef): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_addr.o):b_addr.c:(.text+0xa28): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0xe6): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x2d6): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x40b): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x43b): undefined reference to `[email protected]' 
C:/Mingw-builds/openssl/lib/libcrypto.a(b_sock.o):b_sock.c:(.text+0x4a0): undefined reference to `[email protected]' 

Antwort

0

Nvm habe es funktioniert, indem es richtig Bestellung:

/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 
+0

Siehe http: // Stackoverflow. com/questions/3363398/g-Linking-Reihenfolge-Abhängigkeit-wenn-Verknüpfung-C-Code-zu-C-Code. – Holt