Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openssl/ssl.h not found but installed with homebrew

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

like image 751
Ricain Avatar asked Dec 09 '15 12:12

Ricain


2 Answers

Try put these in your bash or zsh profile.

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
like image 91
chouyangv3 Avatar answered Oct 23 '22 03:10

chouyangv3


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

like image 23
Ricain Avatar answered Oct 23 '22 03:10

Ricain