我有一个简单的C程序使用libssl。在OS X上使用libssl编译C程序El Capitan?
在Linux上,我安装OpenSSL的-dev软件包,并与下面的行编译的程序:
gcc test_libssl.c -o test_libssl -lcrypto -lssl
现在我想这样做我的Mac上。在同一行了:
fatal error: 'openssl/conf.h' file not found
我试图通过brew install openssl
安装OpenSSL时(OpenSSL的-dev的没有工作)与家庭酿造这给了我:
...
==> Installing openssl
==> Downloading https://www.openssl.org/source/openssl-1.0.2a.tar.gz curl: (22) The requested URL returned error: 404 Not Found
我发现了一个related SO question没有答案。
我也试过
brew info openssl
,结果被告知,
This formula is keg-only. Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
我有什么做/安装,以便能够编译在OS X上使用的libssl-C程序的程序?
或者,第一个地方(给出上面的警告)是一个坏主意吗?
UPDATE:
我OpenSSL的使用BREW安装。我不确定这是否是问题,但我更新了酿造。 以酿造的建议
You should probably change the ownership and permissions of /usr/local back to your user account. sudo chown -R $(whoami):admin /usr/local
和this问题考虑在内。
然后,以下@Alex雷诺兹的建议,我成功地与
gcc test_libssl.c -o test_libssl -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
它为过时的理由......你应该在你的应用程序创建OSX特定代码,使用苹果的框架(像libcrypto).. 。 – Macmade
@Macmade libcrypto是OpenSSL的一部分。没有直接相同的本地库;最接近的等价物(这不是很接近)是CommonCrypto。 – duskwuff