2012-09-01 31 views
0

我已經寫在了XCode 4.4.1一些簡單的C++程序每當我編譯它們,我得到的以下錯誤:的XCode 4.4.1 - C++ - 蘋果的Mach-O接頭(ID)錯誤 - 符號(S)沒有找到i386硬件架構

"Main()", referenced from: 
mainWrapper() in libStanfordCPPLib.a(startup.o) 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

是它使得在libStanfordCPPLib.amainWrapper()參考?後面的文件被提供並且可以修改內容?否則,我是否需要進行更改以消除對mainWrapper()的引用?謝謝。

更多細節:

Ld ./BlankProject.app/Contents/MacOS/BlankProject normal i386 
    cd "/Users/benjamin/Documents/Programming/iTunes U/Stanford/CS106B Programming Abstractions/Summer 2012/Programs/Section Handout #2 Question 2" 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch i386 "-L/Users/benjamin/Documents/Programming/iTunes U/Stanford/CS106B Programming Abstractions/Summer 2012/Programs/Section Handout #2 Question 2" -LStanfordCPPLib "-L/Users/benjamin/Documents/Programming/iTunes U/Stanford/CS106B Programming Abstractions/Summer 2012/Programs/Section Handout #2 Question 2/StanfordCPPLib" "-F/Users/benjamin/Documents/Programming/iTunes U/Stanford/CS106B Programming Abstractions/Summer 2012/Programs/Section Handout #2 Question 2" -filelist "/Users/benjamin/Library/Developer/Xcode/DerivedData/BlankProject-fxnhpjsyinnahlexvnlrhbilvwkd/Build/Intermediates/BlankProject.build/Debug/Section Handout #2 Question 4a.build/Objects-normal/i386/BlankProject.LinkFileList" -framework Cocoa -framework Carbon -framework QuickTime -lStanfordCPPLib -o "/Users/benjamin/Documents/Programming/iTunes U/Stanford/CS106B Programming Abstractions/Summer 2012/Programs/Section Handout #2 Question 2/./BlankProject.app/Contents/MacOS/BlankProject" 

Undefined symbols for architecture i386: 
"Main()", referenced from: 
mainWrapper() in libStanfordCPPLib.a(startup.o) 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
+0

這是用於OS X還是iOS? – 2012-09-01 12:03:49

回答

1

看來,無論圖書館使用的是希望你定義一個名爲Main()功能(注意是大寫字母M),而你還沒有這樣做。

+0

謝謝@autopulated。我定義了一個名爲main()的函數。已將其更改爲Main(),但錯誤仍然存​​在。另外,我還有其他程序調用相同的庫libStanfordCPPLib.a,它們編譯時沒有任何問題,它們具有函數main()。 –

+0

@RexF如果你的程序可以工作,那麼最好的辦法可能是查看項目之間編譯設置的差異。 – James

相關問題