I have a simple C program using libssl.
On Linux, I installed the openssl-dev package and compiled the program with the following line:
gcc test_libssl.c -o test_libssl -lcrypto -lssl
Now I would like to do the same on my Mac. The same line resulted in:
fatal error: 'openssl/conf.h' file not found
I tried installing openssl (openssl-dev did not work) with home-brew via brew install openssl
This gave me:
...
==> Installing openssl
==> Downloading https://www.openssl.org/source/openssl-1.0.2a.tar.gz curl: (22) The requested URL returned error: 404 Not Found
I found a related SO question with no answer.
I also tried
brew info openssl
and got informed that
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
What do I have to do / install in order to be able to compile libssl-using C programs programs on OS X?
Or, is it a bad idea the first place (given the warning above)?
UPDATE:
I got the openssl installed using brew. I am not sure if this was the problem but I updated brew. Taking brew's advice
You should probably change the ownership and permissions of /usr/local back to your user account. sudo chown -R $(whoami):admin /usr/local
and this issue into account.
Then, following @Alex Reynolds's advice, I compiled it successfully with
gcc test_libssl.c -o test_libssl -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
I have Homebrew installed on El Capitan (10.11.1) and have installed a current version of OpenSSL with no apparent ill effects:
Have you tried adding the flags that it suggests to your app's build statement? You might edit your app's
makefile
or other build statement and add those entries, after abrew install openssl
. This may help your compiler find and link the library and header files it needs.Looks like everything is there. Here are headers:
And static and dynamic libraries:
The answer of @Alex Reynolds is correct, but if you want to compile/configure someone else's program, then you can run this beforehand: