title: Compiling C programs using libssl on OS X El Capitan?
body: <p>I have a simple C program using libssl.</p>
  
  <p>On Linux, I installed the openssl-dev package and compiled the program with the following line:</p>
  
  <pre><code>gcc test_libssl.c -o test_libssl -lcrypto -lssl
  </code></pre>
  
  <p>Now I would like to do the same on my Mac. The same line resulted in:</p>
  
  <pre><code>fatal error: 'openssl/conf.h' file not found
  </code></pre>
  
  <p>I tried installing openssl (openssl-dev did not work) with home-brew via <code>brew install openssl</code></p>
  
  <p>This gave me:</p>
  
  <blockquote>
    <p>...<br>
    ==> Installing openssl<br>
    ==> Downloading <a href="https://www.openssl.org/source/openssl-1.0.2a.tar.gz" rel="noreferrer">https://www.openssl.org/source/openssl-1.0.2a.tar.gz</a>
    curl: (22) The requested URL returned error: 404 Not Found</p>
  </blockquote>
  
  <p>I found a <a href="https://stackoverflow.com/questions/29651258/install-openssl-devel-on-mac">related SO question</a> with no answer.</p>
  
  <p>I also tried</p>
  
  <pre><code>brew info openssl
  </code></pre>
  
  <p>and got informed that</p>
  
  <blockquote>
    <p>This formula is keg-only.
    Mac OS X already provides this software and installing another version in
    parallel can cause all kinds of trouble.</p>
    
    <p>Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries</p>
  </blockquote>
  
  <p>What do I have to do / install in order to be able to compile libssl-using C programs programs on OS X?</p>
  
  <p>Or, is it a bad idea the first place (given the warning above)?</p>
  
  <p><br>
  <br>
  <br>
  <strong>UPDATE:</strong></p>
  
  <p>I got the openssl installed using brew. I am not sure if this was the problem but I updated brew.
  Taking brew's advice</p>
  
  <blockquote>
    <p>You should probably change the ownership and permissions of /usr/local
    back to your user account.
      <strong>sudo chown -R $(whoami):admin /usr/local</strong></p>
  </blockquote>
  
  <p>and <a href="https://github.com/Homebrew/homebrew/issues/44973" rel="noreferrer">this</a> issue into account.</p>
  
  <p>Then, following @Alex Reynolds's advice, I compiled it successfully with</p>
  
  <pre><code>gcc test_libssl.c -o test_libssl -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
  </code></pre>