未定义对SSL_library_init和SSL_load_error_strings的引用 [英] Undefined reference to SSL_library_init and SSL_load_error_strings
问题描述
我正在实现OpenSSL代码,并且已经包含必需的头文件,但是仍然出现类似*
I am implementing a OpenSSL code and have already included required header files but still I am getting errors like *
对
SSL_library_init
的未定义引用
我想这是链接错误,而不是编译错误.
I guess it's a linking error rather than a compilation error.
我正在使用slickeditor在Linux框中实现它.
I am implementing it in Linux box using slickeditor.
推荐答案
链接到libssl
和libcrypto
.您的LDFLAGS
和LDLIBS
将如下所示. LDLIBS
的订单事项:
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
不用担心在库名之前添加"lib",或者后缀"so"或"a".链接器将为您完成此操作.
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
如果使用系统的OpenSSL,则可以省略-L/usr/local/ssl/lib
.
If you are using the system's OpenSSL, then you can omit -L/usr/local/ssl/lib
.
这篇关于未定义对SSL_library_init和SSL_load_error_strings的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!