Undefined reference to SSL_library_init and SSL_load_error_strings

强颜欢笑 提交于 2019-12-22 03:43:08

问题


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.


回答1:


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.




回答2:


For me this meant to install

 apt install libssl1.0-dev



回答3:


ldd libssl.so -> libcrypto.so.1.1 => not found

sudo ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f17d46c7000)



来源:https://stackoverflow.com/questions/5593284/undefined-reference-to-ssl-library-init-and-ssl-load-error-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!