[MingW] Undefined reference BUT find it with "nm"

Hello,

I am trying to make SSL work with boost ASIO. I am on windows and using MingW 6.3.

I built OpenSSL 1.1, 1.0 and 0.8 with MingW when I try to link them to the project I always get different errors (depending on what is missing). Right now I am trying to make work OpenSSL 1.1.0g but I have those error even though I give manually the path to the libs with CMAKE.

This is the errors if I build my projct with OpenSSL 1.1.0g :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" --build C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug --target AuthServer -- -j 2
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -HC:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer -BC:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\Makefile2 AuthServer
mingw32-make.exe[1]: Entering directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -HC:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer -BC:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -E cmake_progress_start C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug\CMakeFiles 6
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\Makefile2 CMakeFiles/AuthServer.dir/all
mingw32-make.exe[2]: Entering directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\AuthServer.dir\build.make CMakeFiles/AuthServer.dir/depend
mingw32-make.exe[3]: Entering directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug C:\Users\myuser\Documents\MagesBattleAuthServerCPP\AuthServer\cmake-build-debug\CMakeFiles\AuthServer.dir\DependInfo.cmake --color=
mingw32-make.exe[3]: Leaving directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\AuthServer.dir\build.make CMakeFiles/AuthServer.dir/build
mingw32-make.exe[3]: Entering directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
[ 16%] Linking CXX executable bin\Windows\AuthServer.exe
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\AuthServer.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -E remove -f CMakeFiles\AuthServer.dir/objects.a
C:\MinGW\bin\ar.exe cr CMakeFiles\AuthServer.dir/objects.a @CMakeFiles\AuthServer.dir\objects1.rsp
C:\MinGW\bin\g++.exe -g   -Wl,--whole-archive CMakeFiles\AuthServer.dir/objects.a -Wl,--no-whole-archive  -o bin\Windows\AuthServer.exe -Wl,--out-implib,lib\libAuthServer.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\AuthServer.dir\linklibs.rsp
CMakeFiles\AuthServer.dir/objects.a(main.cpp.obj): In function `ZN5boost4asio3ssl6detail17openssl_init_base7do_initD1Ev':
c:/users/myuser/documents/magesbattleauthservercpp/include/boost/asio/ssl/detail/impl/openssl_init.ipp:89: undefined reference to `CONF_modules_unload'
CMakeFiles\AuthServer.dir/objects.a(main.cpp.obj): In function `ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei':
c:/users/myuser/documents/magesbattleauthservercpp/include/boost/asio/ssl/impl/error.ipp:39: undefined reference to `ERR_reason_error_string'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\AuthServer.dir\build.make:217: recipe for target 'bin/Windows/AuthServer.exe' failed
mingw32-make.exe[3]: Leaving directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
CMakeFiles\Makefile2:69: recipe for target 'CMakeFiles/AuthServer.dir/all' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
mingw32-make.exe[3]: *** [bin/Windows/AuthServer.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/AuthServer.dir/all] Error 2
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/AuthServer.dir/rule' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/myuser/Documents/MagesBattleAuthServerCPP/AuthServer/cmake-build-debug'
Makefile:120: recipe for target 'AuthServer' failed
mingw32-make.exe[1]: *** [CMakeFiles/AuthServer.dir/rule] Error 2
mingw32-make.exe: *** [AuthServer] Error 2

Command to build OpenSSL (mingw msys2) :

1
2
$ ./Configure mingw64 no-shared no-asm --prefix=/C/OpenSSL-x64
$ make && make install


linklibs.rsp :

1
2
3
4
5
6
7
8
9
10
11
12
C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_chrono-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_atomic-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_date_time-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_regex-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_thread-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_system-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_iostreams-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libboost_zlib-mgw63-mt-d-1_65_1.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libssl.a
 C:/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libcrypto.a
 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid
 -lcomdlg32 -ladvapi32 -lws2_32 -lwsock32 -lmswsock -ldl -lpthread 



nm of crypto :
1
2
3
4
5
6
7
myuser@LHCFB203 MINGW64 ~
$ nm /C/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libcrypto.a | grep 'CONF_modules_unload'
00000000000005c0 T CONF_modules_unload

myuser@LHCFB203 MINGW64 ~
$ nm /C/Users/myuser/Documents/MagesBattleAuthServerCPP/Lib/win/x64/debug/libcrypto.a | grep 'ERR_reason_error_string'
0000000000004de0 T ERR_reason_error_string


I'm really lost here. What did I do wrong ?
Last edited on
Order of included libraries does matter, sometimes the same library need to be specified multiple times to work correctly. This is due to a "feature" of gnu linker which attempt to be "smart" and save time ( crap behaviour if you ask me )
Topic archived. No new replies allowed.