+ 5

What lib file defines ERR_clear_error, TLS_method... in boost or openssl for c++?

I'm trying to compile some code involving boost and openssl to use HTTPS but am unable to link. Here are the headers I included: #include <boost/beast/core.hpp> #include <boost/beast/http.hpp> #include <boost/beast/version.hpp> #include <boost/asio/connect.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/ssl.hpp> #include <cstdlib> #include <iostream> #include <string> I installed boost 1.760 in Windows 10 if that matters. I installed openssl 1.1. I'm compiling using mingw32-g++ through CodeBlocks. I linked to the following libraries: -s -lglut32 -lopengl32 -lglu32 -lwinmm -lgdi32 "C:\Program Files (x86)\CodeBlocks\MinGW\lib\glut32.lib" -lgdiplus -lws2_32 "C:\Program Files (x86)\CodeBlocks\MinGW\boost_1_76_0\stage\lib\libboost_system-vc142-mt-x64-1_76.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libcrypto.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libssl.lib" -mwindows These are the error messages: ||=== Build: Release in UAV Simulator (compiler: GNU GCC Compiler) ===| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `ERR_clear_error'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `TLS_method'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `SSL_CTX_new'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `SSL_CTX_set_options'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `ERR_clear_error'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `SSL_CTX_set_default_verify_paths'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `ERR_get_error'| obj\Release\io\networking\HTTPDownloader.o:HTTPDownloader.cpp|| undefined reference to `ERR_get_error'| ||error: ld returned 1 exit status| ||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

29th Apr 2021, 12:01 AM
Josh Greig
Josh Greig - avatar
4 Réponses
+ 1
Try changing the linking order to first link libssl and then libcrypto something like this -s -lglut32 -lopengl32 -lglu32 -lwinmm -lgdi32 "C:\Program Files (x86)\CodeBlocks\MinGW\lib\glut32.lib" -lgdiplus -lws2_32 "C:\Program Files (x86)\CodeBlocks\MinGW\boost_1_76_0\stage\lib\libboost_system-vc142-mt-x64-1_76.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libssl.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libcrypto.lib" -mwindow
29th Apr 2021, 5:04 AM
Arsenic
Arsenic - avatar
0
Josh Greig sir actully i installed mingw latest Compiler for c++ 17 features like Kickstart Library but when am Compiling my code via command line its showing errors how to setup Compiler for c++17 can i use without install vs . And in which ide or Compiler you creating such types of program which you have mentioned here its codeblock .
29th Apr 2021, 3:52 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
A.S wrote, "Josh Greig sir actully i installed mingw latest Compiler for c++ 17 features like Kickstart Library but when am Compiling my code via command line its showing errors how to setup Compiler for c++17 can i use without install vs . And in which ide or Compiler you creating such types of program which you have mentioned here its codeblock ." Response: CodeBlocks is the IDE I used: https://www.codeblocks.org/ mingw32-g++ is the compiler. I mentioned the IDE but it might not affect the answer to my question because CodeBlocks runs the compiler and linker commands as if they were run through a command terminal. Do you know what .lib or .a file defines ERR_clear_error? Have you built a c++ project using OpenSSL? I really want to fix this error. This is where I got the OpenSSL lib and headers from: https://raw.githubusercontent.com/CristiFati/Prebuilt-Binaries/master/OpenSSL/v1.1.1/OpenSSL-1.1.1k-Win-pc064.zip I used steps from this video to build Bootstrap on my Windows 10 Home laptop: https://www.youtube.com/watch?v=Mioo8Hnp6M8 That video runs bootstrap.bat for gcc but I specified mingw32-g++ since that's the compiler I'm using for a project. I compiled and tested code using boost/beast and boost/asio headers and libboost_system-vc142-mt-x64-1_76.lib to download a file using HTTP. I have HTTP working very well. HTTPS uses SSL which is why I tried to include the OpenSSL libraries, though. I just can't completely build while using OpenSSL so I'm likely missing some lib in the compile command and hopefully you or someone can point me to a .lib or .a file I should be including.
29th Apr 2021, 4:44 AM
Josh Greig
Josh Greig - avatar
0
Arsenic wrote, "Try changing the linking order to first link libssl and then libcrypto something like this... Response: I still get errors after swapping libssl with libcrypto. I started a separate project to simplify this troubleshooting process. What complete command do you use to compile this? #include <boost/asio/ssl.hpp> int main() { return 0; } Here is the specific command with output that I receive: mingw32-g++.exe -o bin\Debug\httpsPrototype.exe obj\Debug\main.o -lws2_32 "C:\Program Files (x86)\CodeBlocks\MinGW\boost_1_76_0\stage\lib\libboost_system-vc142-mt-x64-1_76.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libssl.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\openssl\lib\libcrypto.lib" obj\Debug\main.o: In function `ZN5boost4asio3ssl6detail17openssl_init_base7do_initD1Ev': C:/Program Files (x86)/CodeBlocks/MinGW/boost_1_76_0/boost/asio/ssl/detail/impl/openssl_init.ipp:90: undefined reference to `CONF_modules_unload' obj\Debug\main.o: In function `ZNK5boost4asio5error6det
29th Apr 2021, 8:33 PM
Josh Greig
Josh Greig - avatar