C语言 对 SSL_library_init 和 SSL_load_error_strings 的未定义引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5593284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 08:20:22  来源:igfitidea点击:

Undefined reference to SSL_library_init and SSL_load_error_strings

copensslundefined-reference

提问by samprat

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

我正在实现一个 OpenSSL 代码并且已经包含了所需的头文件,但我仍然收到像 * 这样的错误

undefined reference to SSL_library_init

未定义的引用 SSL_library_init

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

我想这是一个链接错误而不是一个编译错误。

I am implementing it in Linux box using slickeditor.

我正在使用 slickeditor 在 Linux 框中实现它。

回答by jww

Link against libssland libcrypto. Your LDFLAGSand LDLIBSwould be as follows. Order matters for LDLIBS:

链接反对libssllibcrypto。您的LDFLAGSLDLIBS将如下所示。订单事项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.

不要担心在库名前添加“lib”,或者“so”或“a”后缀。链接器会为你做这件事。

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.

如果您使用的是系统的 OpenSSL,则可以省略-L/usr/local/ssl/lib.

回答by rogerdpack

For me this meant to install

对我来说这意味着安装

 apt install libssl1.0-dev

回答by unDEFER

These methods are deprecated in OpenSSL 1.1. You don't need to use it more. You can just remove it. More info in OpenSSL manual.

这些方法在 OpenSSL 1.1 中已弃用。你不需要更多地使用它。你可以删除它。OpenSSL 手册中的更多信息。

回答by Michael Popovich

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

ldd libssl.so -> libcrypto.so.1.1 => 未找到

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

须藤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)

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