Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode can't find OpenSSL headers in /usr/include

I'm trying to use standard system header files in my C++ XCode project:

#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>

The build fails and it complains:

"Openssl/bio.h: No such file or directory"

I added /usr/include to the "Header Search Paths" in Project settings, but that doesn't fix it.

I can fix it by adding the whole path like:

#include </usr/include/openssl/bio.h>

-- but the project is full of similar includes and I don't want to change all of them this way. Also, I feel I shouldn't have to do this.

Another way to fix it would be as another thread mentioned, which is to add /usr/include to User Header Search Paths. But if I do that, then I'd have to change all the angle brackets <> to quotes "", which again seems like a hack. I mean, these are standard system header files so I feel it should be something simple, not requiring these kinds of hacks.

Any ideas?

Thanks!

like image 952
mindthief Avatar asked May 06 '10 22:05

mindthief


2 Answers

Xcode uses the currently selected SDK as a base path, which it prefixes on to system includes. So if your SDK is /Developer/SDKs/MacOSX10.6.sdk then it will look under /Developer/SDKs/MacOSX10.6.sdk/usr/include by default for system includes.

There are various possible workarounds - I would probably just put a symbolic link in /Developer/SDKs/MacOSX10.6.sdk/usr/include pointing at /usr/include/openssl but you can probably think of others now that you know the underlying problem.

like image 154
Paul R Avatar answered Oct 15 '22 22:10

Paul R


It might depend on the fact that HFS(+) is case insensitive. The error message talks about "Openssl/bio.h" with capital "O", but you're specifying "openssl/bio.h" in the include and the path with /usr/include works.

I suspect that there's some "Openssl" (capital "O") directory in your include path, that gets used when looking for "openssl/bio.h". This wouldn't happen if HFS(+) were case sensitive from the very beginning (I know it's possible to have is case sensitive, but it's actually a PITA to use...)

like image 32
polettix Avatar answered Oct 16 '22 00:10

polettix