Fatal error in building SQLCipher ('openssl/rand.h' file not found) Fatal error in building SQLCipher ('openssl/rand.h' file not found) sqlite sqlite

Fatal error in building SQLCipher ('openssl/rand.h' file not found)


I encountered this specifically for a golang library I was trying to install. I was getting the following error when I tried to run go get github.com/xeodou/go-sqlcipher:

# github.com/xeodou/go-sqlcipherproject/src/github.com/xeodou/go-sqlcipher/sqlite3-binding.c:18280:10: fatal error: 'openssl/rand.h' file not found

I fixed this by adding the following to my bash profile:

export CGO_LDFLAGS="-L/usr/local/opt/openssl/lib"export CGO_CPPFLAGS="-I/usr/local/opt/openssl/include"

Hopefully this helps.


Make sure that brew has linked to openssl libraries correctly. Run this command

 brew link openssl --force

Then try again.


I didn't have brew on my machine, but I fixed this error a different way. In Xcode, I went to Preferences->locations->"source trees"-> Click +, set OPENSSL_SRC to "full-path-to-openssl-source"