How to add OpenSSL to an Xcode project

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 to the openssl-devel package available as part of the OS or with homebrew or some?

+7
source share
2 answers

You will need to compile and link it yourself, and your application should send it. If your application license and OpenSSL license are compatible, you can use static binding. Otherwise, you will need to dynamically link it.

There are several documents describing the process and creating scripts that you can find when you search Google. For iOS, there is even a Github project . I have not copied the contents of these documents here, as this is too much, and this is a moving target.

You can also install OpenSSL using Homebrew. If you just want your application to 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 application, you will need to copy the library / libraries into your application suite and make sure that the linker finds it there. It also has the disadvantage that it is possible to โ€œdisconnectโ€ between your application and the version of OpenSSL: if in a year you update OpenSSL with Homebrew and want to compile / link an older version of your application with the same version of OpenSSL as you did at the time you had a problem.

+8
source
  1. Download source code from openssl .
  2. Extract the compressed file to the directory of your choice. .
  3. Open a command prompt and go to this directory and enter something similar to ./configure darwin64-x86_64-cc .
  4. Then type make depend .
  5. Then make install .
  6. Go to the build settings of your Xcode project. In the "Search paths in the header" section, add /usr/local/ssl/include and the search paths in the /usr/local/ssl/lib library (or any other installation paths that you selected during the configuration step). .
  7. Also in the build settings, go to Linking and put -lssl -lcrypto under other linker flags

You should be good to go.

+6
source

Source: https://habr.com/ru/post/1234513/


All Articles