mindthief
mindthief

Reputation: 13383

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!

Upvotes: 11

Views: 16273

Answers (3)

leontx
leontx

Reputation: 1195

I've been able to avoid having to specify paths on includes by simply making sure to select Create groups for any added folders for the Folders option in the Add Files to Project dialog which pops up when you're adding the files.

With the other option, Create folder reference for any added folders, I have to manually point it to the file via the full path (and the folder icons show up blue instead of the normal beige). Interestingly, even in this case, AutoComplete sees the file, but Xcode complains it can't find it.

Upvotes: 0

Paul R
Paul R

Reputation: 212949

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.

Upvotes: 14

polettix
polettix

Reputation: 507

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...)

Upvotes: 1

Related Questions