I am trying to port an application to mac OSX. It uses openssl. I am new to xcode and mac development. Do I need to compile and install openssl myself, or is there some equivalent of an openssl-devel package available as part of the OS or with homebrew or some such?
3 Answers
- Download source from openssl source .
- Extract compressed file into directory of your choice. .
- Open command line and go to that directory and type something similar to
./configure darwin64-x86_64-cc
. - Then type
make depend
. - Then
make install
. - Go to your Xcode project build settings. Under Header Search Paths add
/usr/local/ssl/include
and library search paths/usr/local/ssl/lib
(or whatever install paths you chose in the configure step) . - Still in build settings go to Linking and under other linker flags put
-lssl -lcrypto
You should be good to go now.

- 8,598
- 83
- 57
- 92

- 513
- 5
- 10
You will need to compile and link it yourself, and your app needs to ship it. If the license of your app and OpenSSL's license are compatible, you may use static linking. Otherwise you will need to dynamically link it.
There are a few documents describing the process and build scripts that you can find with Google searches. For iOS, there's even a Github project. I didn't copy the contents of those documents here since it's too much and it's a moving target.
You can also install OpenSSL with Homebrew. If you just want to have your app run on your Mac and you don't want to distribute it, this is the easiest way: you just need to link it. But if you want to distribute your app, you would need to copy the library/libraries to your app bundle and make sure the the linker finds it there. This also has the disadvantage that there's a possible "disconnect" between your app and the OpenSSL version: if in one year, you update OpenSSL with Homebrew and want to compile/link an older version of your app against the very same OpenSSL version as you've used at that time, you have a problem.

- 90,870
- 19
- 190
- 224
-
-
Nothing. It has exactly the same advantages/issues as the Homebrew solution. – DarkDust Oct 26 '15 at 08:38
-
1I don't follow the disadvantage. If you link against static library or the dynamic library (and include it in the app bundle) you are completely detached from whatever version is installed via homebrew/macports. The advantage, however, to using homebrew/macports is enormous when it comes to building the library in the first place. – trojanfoe Oct 26 '15 at 08:40
-
The disadvantage is that you don't have all components in your VCS. To me, it's very important to be able to reproduce an old build as exactly as possible, so the Homebrew/Macports solution would not be an option for me. Also, you might inadvertently break your build when the brew/port is updated to a version with API changes. Other people may not care about that; for those, using the Homebrew/Macports version and simply copying the library to their bundle (and _double checking whether the dynamic linker is really using the bundled version_) is indeed the easiest option. – DarkDust Oct 26 '15 at 09:05
-
1I installed openssl with homebrew, but I think it only installed the openssl executable, not the development libraries and headers. Where would I find them? Do I need to manually add them to the xcode project? – Baruch Oct 26 '15 at 09:39
-
@baruch: On my system, the headers are in `/usr/local/Cellar/openssl/1.0.2d_1/include/openssl`. Use `brew ls openssl` to see the installed files (it does omit some files in subdirectories, though). Yes, you manually need to add the `/usr/local/Cellar/openssl/1.0.2d_1/include` directory to your _Header Search Paths_ in your project. – DarkDust Oct 26 '15 at 10:32
-
1@DarkDust Thank you. One last thing (I am new to xcode) - I can't seem to find where to add the link dependency. I added the `openssl/lib` to the library search path, but how do I tell it to link the libraries? – Baruch Oct 26 '15 at 10:44
-
@baruch: Click on your project in the navigator, then on _Build Phases_ tab. Expand the _Link Binary with Libraries_ section and click the "+" button. Then click _Add Other…_ and select the library file. – DarkDust Oct 26 '15 at 11:14
i tried today starting of 2020
install openssl with homebrew
brew install openssl
this will install openssl version 1.1d in
/usr/local/Cellar/openssl@1.1/1.1.1d/lib/
add both libcrypto.a and libssl.a
brew will not make a symbolic link to /usr/local/lib

- 506
- 4
- 15
-
When I tap Link Binary With Libraries, there are no such libraries in the list. I create Xcode -> new command line app -> select C language. – Alisher Jan 07 '22 at 11:44
-
try symbolic linking the library ln -s /usr/local/Cellar/openssl@1.1/1.1.1d/lib/libcrypto.a /usr/local/lib and same with libssl.a unfortunately i dont work directly with xcode – Sherif O. Jan 08 '22 at 13:46