2014-04-06 58 views
7

什麼會導致類似這樣的錯誤?我向Xcode添加了一個空項目,在Header Search Paths中添加了/ usr/local/lib,並添加了一些opencv庫。建築給了這些錯誤:cstdint中的錯誤:全局命名空間中沒有名爲xxx的成員

UPDATE

看來stdint.h是我的系統上安裝確實。我在OS 10.9上運行,因此xcode在全局名稱空間中找不到的類型如int_least16_t似乎已被定義。

typedef int16_t int_least16_t;

find /Applications/Xcode.app -name stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/c++/4.2.1/tr1/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/c++/4.2.1/tr1/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/c++/4.2.1/tr1/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/tr1/stdint.h 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdint.h 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include/stdint.h 
+0

您是否也啓用了C++ 11支持? – lpapp

+0

是的,我正在使用的C++標準庫是libC++(支持C++ 11的LLVM C++標準庫)。我也使用C++語言方言GNU ++ 11。使用方言C++ 11時會發生同樣的錯誤。我確信我使用的編譯器(Apple LLVM 5.1)確實正在使用這些選項。 –

+0

您是否確認過您的系統中已安裝'stdint.h',並且這些類型是在其內部聲明的? 「 – Amadeus

回答

8

感謝@牛米,我才知道,直接/usr/local下安裝任何東西是從根本上打破,因爲隨後的版本地獄。我可能在/usr/local/include有一些不良因素,所以當我用/usr/local/Cellar/opencv/2.4.8.2/include/opencv2(因爲我使用brew安裝了opencv)替換usr/local/include時,在Xcode > Build Settings > Header Search Paths(遞歸True)中一切正常。

相關問題