openssl/ssl.h not found but installed with homebrew

半世苍凉 提交于 2019-12-10 02:56:15

问题


I am working on a C++ project on my Mac running El Capitan and I get this error even after installing openssl with Homebrew:

g++ -Wall -g -std=c++11 -I../libSocket/src -I../libData/src  -c src/fsslhandler.cpp -o obj/fsslhandler.o
In file included from src/fsslhandler.cpp:1:
In file included from src/fsslhandler.h:8:
../libSocket/src/sslsocket.h:6:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make: *** [obj/fsslhandler.o] Error 1

After searching for a solution I found one which does not work:

brew link openssl --force

In order to make it work, I have to add the following flags at compilation:

LDFLAGS: -L/usr/local/opt/openssl/lib

CPPFLAGS: -I/usr/local/opt/openssl/include

How to make it work without this flags?

Openssl use to work on El Capitan installed with brew, but I reinstalled OS X and update openssl with homebrew and here I am.

Thank


回答1:


I found the solution: clang was not looking in the right place.

xcode-select --install

This post resolved this issue: On mac, g++ (clang) fails to search /usr/local/include and /usr/local/lib by default




回答2:


You can also use an Apple Developer Account to download the standalone option

https://developer.apple.com/download/more

You'll see something like this:



来源:https://stackoverflow.com/questions/34178988/openssl-ssl-h-not-found-but-installed-with-homebrew

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