2011-07-02 24 views
1

我一直在試圖將我的pThread類移植到iOS。因此,我已將它們全部移到我的XCode項目中,並放入名爲「Threading」的主要文件的子目錄中。相對標題XCode 4

但是我無法編譯。在pThreadThread.cpp,例如,它有一個

#include "Threading/pThreadThread.h" 

,但返回的XCode我一個錯誤說,它不能找到頭。我假設這是因爲它從目錄中查看標題當前所在。因此,在前面添加「../」似乎有幫助,但它不是一個很好的解決方案,IMO。

所以我發現這個線程:

XCode 4 Relative #include paths in search?

但在嘗試它似乎不工作的解決方案。首先我注意到實際的源數據在$ SRCROOT /下,所以我在(首先在User Header路徑下,然後,因爲在正常的頭文件路徑下工作不起作用),並且...它仍然沒有工作。

怎麼回事?我如何獲得相關頭文件,包括實際工作?

編輯:命令行看起來是這樣的

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/include -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. 
+0

加載我的項目是什麼,你要添加頁眉路徑?包含pThreadThread.h的目錄或包含Threading目錄的目錄?後者是你應該包含在標題路徑中。 –

+0

@Ben Hocking:$ SRCROOT/指向我的Threading子目錄所在的目錄,但我仍然得到相同的構建錯誤。 – Goz

+0

另請注意......我已經檢查並重複檢查過......它絕對指向線程目錄是其子目錄的目錄。 – Goz

回答

3

要非常小心Xcode如何用空格解釋路徑。就我而言,我的

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

成爲

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

檢查你的路像頭搜索路徑項目設置並添加雙引號到您的路徑。

"$(PROJECT_DIR)/YOURLIBRARY" 

代替

$(PROJECT_DIR)/YOURLIBRARY 

這個問題讓我當我試圖從非引導卷

0

我猜這條道路:

/卷/開發磁盤/開發/牛津 波 研究/ VoiceAnalyser/VoiceAnalyser/Threading /../ Threading/pthreadThread.h

...是無意的。你的頭搜索路徑應該下定決心:

/卷/開發磁盤/開發/牛津 波 研究/ VoiceAnalyser/VoiceAnalyser/

...如果你想使用「線程/ whatever.h「子路徑。

+0

但是地獄是XCode從那裏得到?用戶標題搜索路徑設置爲/ Volumes/Dev Disk/Development/Oxford Wave Research/VoiceAnalyser/VoiceAnalyser/... – Goz

+0

雙擊該值併發布實際設置(而不是當設置爲'正在編輯)。 –

+0

掛在一秒 - 它說它正在上漲並再次下降,因爲它包含在pthreadThread.cpp中。包含應該是「pthreadThread.h」而不是「Threading/pthreadThread.h」,因爲它位於同一個文件夾中。 –

0

您需要將目錄添加到包含它的項目的「生成設置」中的頁眉搜索路徑中。