开发者

Relative headers XCode 4

I've been trying to port my pThread classes over to iOS. As such I have moved them all across to my XCode project into a subdirectory from the main files called "Threading".

However I can't compile. In the pThreadThread.cpp, for example, it has a

 #include "Threading/pThreadThread.h"

and yet XCode returns me an error saying it can't find the header. I'm assuming this is because it is looking from the directory that the header is currently in. As such adding "../" on the front does seem to help, however its not a very good solution, IMO.

So I found this thread:

XCode 4 Relative #include paths in search?

But on trying the solution it doesn't seem to work. First thing I noticed was that the actual source data was under $SRCROOT/ so I added that in (Firstly under User Header paths and then, because that didn't work, under normal header paths) and ... it still doesn't work.

Whats going on? How can I get relative header including to actually work?

Edit: The command line looks like this

CompileC /Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/Objects-normal/i386/pthreadThread.o VoiceAnalyser/Threading/pthreadThread.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd "/Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser"
    setenv LANG en_US.US-ASCII
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -x c++ -arch i386 -fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -O0 -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -DDEBUG=1 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fexceptions -fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -fvisibility-inlines-hidden -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -iquote /Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/VoiceAnalyser-generated-files.hmap -I/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/VoiceAnalyser-own-target-headers.hmap -I/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/VoiceAnalyser-all-target-headers.hmap -iquote /Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/VoiceAnalyser-project-headers.hmap -iquote/Volumes/Dev -iquoteDisk/Development/Oxford -iquoteWave -iquoteResearch/VoiceAnalyser -I/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Products/Debug-iphonesimulator/开发者_如何学Pythoninclude -I/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/DerivedSources/i386 -I/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/DerivedSources -F/Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Products/Debug-iphonesimulator -include /Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/PrecompiledHeaders/VoiceAnalyser-Prefix-dzvjbuvabxhsdtfseyyxyapbsuqv/VoiceAnalyser-Prefix.pch -c "/Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/Threading/pthreadThread.cpp" -o /Users/oscarforth/Library/Developer/Xcode/DerivedData/VoiceAnalyser-baxcnwbmyjmkfncxfxoaltcqbrzr/Build/Intermediates/VoiceAnalyser.build/Debug-iphonesimulator/VoiceAnalyser.build/Objects-normal/i386/pthreadThread.o

In file included from /Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/Threading/pthreadThread.cpp:1:
/Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/Threading/../Threading/pthreadThread.h:44:10: fatal error: 'Threading/pThreadEvent.h' file not found [2]
 #include "Threading/pThreadEvent.h"
          ^
1 error generated.


Be very careful about how Xcode interprets path with spaces. In my case, my

-I/Volumes/Macintosh HD/Users/...

becomes

-I/Volumes/Macintosh -IHD/Users/...

check your paths in project settings like Header Search Path and add double quote to your path.

"$(PROJECT_DIR)/YOURLIBRARY"

instead of

$(PROJECT_DIR)/YOURLIBRARY

This issue got me when I tried to load my project from non-boot volume


I'm guessing this path:

/Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/Threading/../Threading/pthreadThread.h

... is unintentional. Your header search path should resolve to:

/Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/

... if you want to use the "Threading/whatever.h" subpath.


You need to add the directory to the Header Search Path in the Build Settings of the project that includes it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜