Reputation: 4940
I am trying to link ssl library to my compilation command. I installed it via
sudo apt-get install libssl-dev
any my compiliaton command
g++ -Wall -pedantic -std=c++11 -lcrypto -lssl file.cpp
Yet it complains:
:(.text+0x19b): undefined reference to `SSL_library_init'
:(.text+0x1a0): undefined reference to `SSLv23_client_method'
:(.text+0x1a8): undefined reference to `SSL_CTX_new'
:(.text+0x1ff): undefined reference to `SSL_CTX_ctrl'
:(.text+0x20e): undefined reference to `SSL_new'
:(.text+0x26b): undefined reference to `SSL_set_fd'
:(.text+0x2b6): undefined reference to `SSL_get_peer_certificate'
:(.text+0x399): undefined reference to `PEM_write_X509'
:(.text+0x41d): undefined reference to `SSL_write'
(.text+0x511): undefined reference to `SSL_read'
All sources indicates that my linking is correct. I had same problem with crypto library but using installing command fixed it (seems like I didn't have it )
I am running Ubuntu.
Upvotes: 3
Views: 3067
Reputation: 16843
Note ssl
should be placed before crypto
.
You may also try to add "/usr/local/ssl/lib" to linker search path:
g++ -Wall -pedantic -std=c++11 -lssl -lcrypto file.cpp -L/usr/local/ssl/lib
Upvotes: 1
Reputation: 896
You can try link it statically like that:
g++ -Wall -pedantic -std=c++11 /usr/lib64/libcrypto.a file.cpp
or
g++ -Wall -pedantic -std=c++11 /usr/lib/libcrypto++.a file.cpp
or
g++ -Wall -pedantic -std=c++11 /usr/lib/x86_64-linux-gnu/libcrypto.a file.cpp
or
g++ -Wall -pedantic -std=c++11 /usr/lib64/libcrypto.so file.cpp
Choose one of the above, depends on the location of the file on your device
Upvotes: 1