How to add OpenSSL to an Xcode project

后端 未结 3 416
星月不相逢
星月不相逢 2020-12-16 20:30

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 equi

相关标签:
3条回答
  • 2020-12-16 20:51

    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

    0 讨论(0)
  • 2020-12-16 20:58

    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.

    0 讨论(0)
  • 2020-12-16 21:02
    1. Download source from openssl source .
    2. Extract compressed file into directory of your choice. .
    3. Open command line and go to that directory and type something similar to ./configure darwin64-x86_64-cc .
    4. Then type make depend .
    5. Then make install .
    6. 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) .
    7. Still in build settings go to Linking and under other linker flags put -lssl -lcrypto

    You should be good to go now.

    0 讨论(0)
提交回复
热议问题