Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将库添加到Xcode 6中的C项目中_C_Xcode_Cs50 - Fatal编程技术网

如何将库添加到Xcode 6中的C项目中

如何将库添加到Xcode 6中的C项目中,c,xcode,cs50,C,Xcode,Cs50,我对这方面还比较陌生,但我会尽量提供详细的信息。我最初试图提供一个屏幕截图,但如果没有10个声誉,我无法做到这一点,所以我将在底部复制并粘贴错误消息作为文本 我正在研究哈佛CS50习题集1。作为其中的一部分,你应该使用为课程作业提供的图书馆。它有两个文件:cs50.h和cs50.c 我下载了这些文件,一开始我遇到了一个错误,我发现是因为它是一个32位的库,我运行的是64位的。我通过进入“项目>构建阶段>将二进制文件链接到库”更改了引用库的位置,因为我在网上找到的结果表明,如果我在这里处理它,Xc

我对这方面还比较陌生,但我会尽量提供详细的信息。我最初试图提供一个屏幕截图,但如果没有10个声誉,我无法做到这一点,所以我将在底部复制并粘贴错误消息作为文本

我正在研究哈佛CS50习题集1。作为其中的一部分,你应该使用为课程作业提供的图书馆。它有两个文件:cs50.h和cs50.c

我下载了这些文件,一开始我遇到了一个错误,我发现是因为它是一个32位的库,我运行的是64位的。我通过进入“项目>构建阶段>将二进制文件链接到库”更改了引用库的位置,因为我在网上找到的结果表明,如果我在这里处理它,Xcode将负责确保正确的体系结构(32位与64位)

现在,我得到了黄色的错误,说明在我尝试构建时它正在传递这些文件,因为它是一种意外的文件类型

我找到了一个使用文件检查器查看类型的建议,我在各种可用的C文件类型中轮换,看看它是否能修复任何问题,但我没有运气

我还发现了另一个关于这一点的对话,指出将架构类型更新为通用选项会有所帮助,但这并没有改变任何事情

在这一点上,我无法通过谷歌搜索找到任何似乎与我的问题有关的东西

我也意识到,由于我的新生,我刚刚做了一件非常愚蠢的事情,但我觉得我已经花了很多时间试图解决这个问题。谢谢你的帮助

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)

这些是源代码文件,需要与您构建的应用程序一起编译。 从您所说的,看起来您正在尝试链接这些文件,就好像它们已经编译过一样

您应该从“将二进制文件与库链接”阶段中删除它们,并将“.c”文件添加到项目的“编译源代码”阶段(仅“.c”文件,因为只有该文件实际包含需要编译的代码。“.h”文件是一个旨在通知其他人该代码提供的函数接口的文件)


这基本上就是链接器在警告中试图告诉您的:在构建的这个阶段找到源代码文件是很混乱的

请投票。再加上一次投票,你应该有10个否认,并能够上传截图。我想屏幕截图会让你更容易得到帮助。我的代码构建成功了!非常感谢你。我很难过,我没有足够的声誉来投票给你(您可以点击左侧的“勾号”接受答案。很高兴您的问题得到解决