It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using OpenSSL headers in C on a Macbook Pro

Sam Caldwell Atlassian Team Mar 13, 2016

This last week, I took the opportunity during the Atlassian ShipIt to work on my CRSCE compression algorithm, rewriting the crsce utility in C rather than Python (for speed and other efficiencies).  But while writing the HSM Buffer, I got the following error from the compiler:

In file included from ./hsm_buffer.h:3:
In file included from ./crypto/crypto.h:17:
./crypto/crypto.c:24:18: fatal error: 'openssl/sha.h' file not found
        #include <openssl/sha.h>

 

I was trying to compile my project on a Mac Book Pro (El Capitan) using GCC.  While I know that Mac provides its own encryption libraries (and plan to support them at some point), most people interested in CRSCE will want to use it on a Linux or Windows machine (and that means OpenSSL is the greatest bang for the buck.

1 answer

1 accepted

5 votes
Answer accepted
Sam Caldwell Atlassian Team Mar 13, 2016

Here's the fix I came up with...

(1) Install openSSL using brew:

brew install openssl --upgrade

I already had openssl installed but the upgrade to El Capitan broke the libraries. So, reinstalling with --upgrade helped me fix my broken state.

 

(2) When compiling, I had been using:

gcc main.c -o crsce

What I should be doing is...

gcc main.c \
    -o crsce \
    -I /usr/local/opt/openssl/include \
    -L /usr/local/opt/openssl/lib

 

The conclusion is that this works now and all is well in the world...

#ifdef OS_MAC
    #ifdef CRSCE_CRYPTO_OPENSSL
        //
        // If using MAC, be sure to...
        //
        //      brew install openssl
        //
        // to install openssl library, then when building use...
        //
        //      gcc <topLevel.c> \
        //          -o <binaryName> \
        //          -I /usr/local/opt/openssl/include \
        //          -L /usr/local/opt/openssl/lib
        //
        // which will tell GCC where the files are located.
        //
        #include <openssl/sha.h>
        #define CRSCE_CRYPTO_READY openssl
    //
    //#elif CRSCE_CRYPTO_<PACKAGENAME>
    //  #include "...path.../file.h"
    //
    #else
        #pragma GCC error ("No recognized crypto package included")
    #endif
    #ifdef CRSCE_CRYPTO_READY
        #pragma message ("A Crypto Package has been included")
    #else
        #pragma GCC error ("No crypto package has been included in crypto.c")
    #endif

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Off-topic

Do you still play the same games you played when you were a kid?

Months ago, I was walking in a huge grocery store and I went to the toys aisle and found a jigsaw puzzle that was more than 50% off, and I thought "why not? It will be fun and it can be a beautiful f...

215 views 21 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you