2014-10-16 55 views
4

我對此很新,但我會盡量提供儘可能詳細的信息。我最初嘗試提供屏幕截圖,但是如果沒有10個聲望,我不能這樣做,所以我將複製並粘貼錯誤消息作爲底部的文本。如何在Xcode 6中將庫添加到我的C項目中

我在哈佛大學CS50問題集1上工作。作爲其中的一部分,您應該使用爲課程提供的庫。它有兩個文件:cs50.h和cs50.c

我已經下載了這些文件,最初我收到一個錯誤,我發現這是因爲它是一個32位庫,我正在運行64位。我通過轉到Project> Build Phases> Link Binary with Libraries,改變了我在引用庫的位置,因爲我在網上發現的內容表明,如果我在這裏處理它,Xcode將負責確保正確的體系結構等等(32位與64位)。

現在我收到了黃色錯誤,指出它在我嘗試構建時傳遞這些文件,因爲它是一個意外的文件類型。

我發現了一個建議,使用文件檢查器來查看類型,我旋轉了各種可用的C文件類型,看看它是否會解決任何問題,我沒有運氣。

我還發現另一個對話,表示更新體系結構類型爲Universal選項會有所幫助,但這並沒有改變任何內容。

此時,我無法通過Google搜索找到與我的問題相關的任何內容。

我也意識到,由於我的新穎性,我剛剛做了一些非常愚蠢的事情,但我覺得我花了很多時間來解決這個問題。我感謝任何幫助。

warning: skipping file '/Users/matthewcanova/Documents/include/cs50.h' (unexpected file type 'sourcecode.c.h' in Frameworks & Libraries build phase) 
warning: skipping file '/Users/matthewcanova/Documents/include/cs50.c' (unexpected file type 'sourcecode.c.c' in Frameworks & Libraries build phase) 
Warning: skipping file '/Users/matthewcanova/Documents/include/cs50.h' (unexpected file type 'sourcecode.c.h' in Frameworks & Libraries build phase) 
Warning: skipping file '/Users/matthewcanova/Documents/include/cs50.c' (unexpected file type 'sourcecode.c.c' in Frameworks & Libraries build phase) 

Ld /Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1- hkvfcrlbsfojiafrcnafkxgoannu/Build/Products/Debug/Problem\ Set\ 1 normal x86_64 
cd "/Users/matthewcanova/Documents/Problem Set 1" 
export MACOSX_DEPLOYMENT_TARGET=10.9 


    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1-hkvfcrlbsfojiafrcnafkxgoannu/Build/Products/Debug -F/Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1-hkvfcrlbsfojiafrcnafkxgoannu/Build/Products/Debug -filelist /Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1-hkvfcrlbsfojiafrcnafkxgoannu/Build/Intermediates/Problem\ Set\ 1.build/Debug/Problem\ Set\ 1.build/Objects-normal/x86_64/Problem\ Set\ 1.LinkFileList -mmacosx-version-min=10.9 -Xlinker -dependency_info -Xlinker /Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1-hkvfcrlbsfojiafrcnafkxgoannu/Build/Intermediates/Problem\ Set\ 1.build/Debug/Problem\ Set\ 1.build/Objects-normal/x86_64/Problem\ Set\ 1_dependency_info.dat -o /Users/matthewcanova/Library/Developer/Xcode/DerivedData/Problem_Set_1-hkvfcrlbsfojiafrcnafkxgoannu/Build/Products/Debug/Problem\ Set\ 1 

Undefined symbols for architecture x86_64: 
    "_GetInt", referenced from: 
     _getPyramidHeight in main.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
+0

採取upvote。與另一個upvote你應該有10 reputiation並能夠上傳屏幕截圖。我猜測截圖會讓你更容易幫助你。 – nburk 2014-10-16 22:34:25

回答

2

這些是源代碼文件,需要與您構建的應用程序一起編譯。 從你說的話看,你似乎試圖鏈接這些文件,就好像它們已經被編譯一樣。

您應該從「Link Binary with Libraries」階段中將它們移除,並將'.c'文件添加到項目的「Compile source」階段(僅限於'.c'文件,因爲只有該文件實際包含代碼需要被編譯,'.h'文件是一個文件,旨在告知其他人提供的代碼所提供的功能的接口)

這基本上是鏈接器試圖告訴你的警告:它很困惑找到在這個階段的源代碼文件

+0

我的代碼成功構建!非常感謝。我很難過,我沒有足夠的聲望來投票給你。 :( – 2014-10-16 22:44:22

+0

你可以通過點擊左邊的「打勾」來接受答案。很高興你的問題解決了 – Olotiar 2014-10-16 23:05:06

相關問題