Xcode Cannot Find Headers from Shared lib in Same Project
Xcode Cannot Find Headers from Shared lib in Same Project
- Subject: Xcode Cannot Find Headers from Shared lib in Same Project
- From: Andreas Grosam <email@hidden>
- Date: Sat, 13 Feb 2010 23:05:30 +0100
Hello all,
I have a project containing two targets, one for a shared library and one for a test program which links to this library, performing some tests.
Say, the shared library's name is "abc" - which is also the project's and the respective target name. The other target is the test application. Target is named "test".
The shared library has public headers and private headers. When deployed, the library and headers shall be installed as follows:
libabc.dylib goes to: /usr/local/lib/
public headers go to: /usr/local/include/abc/
private headers go to: /usr/local/include/abc/internal/
This has been actually achieved by setting the roles of the public headers to "public" and the private ones to "private" respectively, and also setting PRIVATE_HEADERS_FOLDER_PATH and PUBLIC_HEADERS_FOLDER_PATH in the build settings accordingly (Deployment category).
So, when compiling with build setting DEPLOYMENT_LOCATION = YES, the headers and the lib are actually copied to the correct locations (for test installs it goes to /tmp/ ...).
If the build setting DEPLOYMENT_LOCATION equals NO (which is usually the case during development), the library and the header files will be copied to the following locations (Debug configuration):
libabc.dylib: $(SRCROOT)/build/Debug
public headers: $(SRCROOT)/build/Debug/usr/local/include
private headers: $(SRCROOT)/build/Debug/usr/local/include/internal
SRCROOT is where the xcode project resides.
So far so good. The shared library compiles fine, and *would* install to the intended location correctly. Since the project is still in development, no deployment has been performed yet. That is, when building, the library and the headers will be copied to the $(SRCROOT)/build/Debug directory - and the headers and the lib in the install location do not exist.
During building xcode also creates these two directories:
$(SRCROOT)/build/abc.build/Debug/abc.build
$(SRCROOT)/build/abc.build/Debug/test.build
which contain temporary build stuff and header maps.
The test program includes a public header from the library and performs some test functions.
Basically it looks like this:
#include <abc/abc.hpp>
int main() {
...
}
So, here the compiler fails, because it cannot find the include headers.
So, what's going on?
I added a compiler switch -v in order to get more info. Here is the relevant info what gcc prints out:
...
ignoring nonexistent directory "/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/Debug/include"
...
#include "..." search starts here:
/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/abc.build/Debug/test.build/test-generated-files.hmap (headermap)
/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/abc.build/Debug/test.build/test-project-headers.hmap (headermap)
#include <...> search starts here:
/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/abc.build/Debug/test.build/test-own-target-headers.hmap (headermap)
/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/abc.build/Debug/test.build/test-all-target-headers.hmap (headermap)
/Users/<>/Develop/abc/abc-0.7.3/Xcode/abc/build/Debug (framework directory)
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/backward
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include
/Developer/SDKs/MacOSX10.6.sdk/usr/include
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks (framework directory)
/Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks (framework directory)
So, it looks like
1)
$(SRCROOT)/build/Debug/include does not exist (that's right)
and
2) the header-maps paths
$(SRCROOT)/build/abc.build/Debug/test.build/test-own-target-headers.hmap (headermap)
$(SRCROOT)/build/abc.build/Debug/test.build/test-all-target-headers.hmap (headermap)
do not contain the correct?/expected header search paths to the library's include directory. I'm also wondering whether they should include them at all. Adding a path to $(SRCROOT)/build/Debug/usr/local/include/abc would do the trick as well.
So, how can I accomplish what I intended? Is this a bug in Xcode?
I also tried setting USE_HEAFERMAPS to NO in one and in both targets, but it didn't help.
Regards
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden