Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined reference to SSL_library_init and SSL_load_error_strings

I am implementing a OpenSSL code and have already included required header files but still I am getting errors like *

undefined reference to SSL_library_init

I guess it's a linking error rather than a compilation error.

I am implementing it in Linux box using slickeditor.

like image 944
samprat Avatar asked Apr 08 '11 09:04

samprat


2 Answers

Link against libssl and libcrypto. Your LDFLAGS and LDLIBS would be as follows. Order matters for LDLIBS:

LDFLAGS = -L/usr/local/ssl/lib
LDLIBS = -lssl -lcrypto

Don't worry about adding the "lib" in front of library name, or the "so" or "a" suffix. The linker will do it for you.

If you are building from the command line, then you would use the following. Again, order matters.

gcc foo.c -o foo.exe -L/usr/local/ssl/lib -lssl -lcrypto

If you are using the system's OpenSSL, then you can omit -L/usr/local/ssl/lib.

like image 84
jww Avatar answered Oct 14 '22 12:10

jww


For me this meant to install

 apt install libssl1.0-dev
like image 12
rogerdpack Avatar answered Oct 14 '22 12:10

rogerdpack