GCC中的OpenSSL链接选项

GCC中的OpenSSL链接选项

本文介绍了GCC中的OpenSSL链接选项-lssl和-lcrypto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加链接选项后:-lssl和-lcrypto,我的程序被正确编译。
但是,我发现GCC不包括这两个选项,所以选项来自哪里? 告诉我们 -l 是链接库的选项。

  -llibrary 
-l library
链接时搜索名为library的库。 (第二种替代方法是使用
库作为单独的参数,仅用于POSIX合规性,并且不建议使用
。)

所以你要告诉gcc链接库ssl和crypto。这些库通常安装在 / usr / lib 中。在Linux上,它们将被称为 libssl.so libcrypto.so 。在OS X上,它们将被称为 libssl.dylib libcrypto.dylib


After adding the link options: -lssl and -lcrypto, my program was correctly compiled.However, I found GCC doesn't include the two options, so where do the options come from?

解决方案

The GCC documentation tells us that -l is the option to link with a library.

-llibrary
-l library
Search the library named library when linking. (The second alternative with the
library as a separate argument is only for POSIX compliance and is not
recommended.)

So you're telling gcc to link with the libraries "ssl" and "crypto". These libraries are typically installed in /usr/lib. On Linux they'll be called libssl.so and libcrypto.so. On OS X they'll be called libssl.dylib and libcrypto.dylib.

这篇关于GCC中的OpenSSL链接选项-lssl和-lcrypto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:03