我已经查看了所有有关Mach-0 Linker的问题,但找不到与我的问题有关的任何问题。我的应用程序在调试器中编译了好几周都没有问题,这似乎是天花乱坠。问题似乎指向两个源文件(keypad.o和setoutput.o)。以前的Mach-O错误通常告诉我,某某文件无法引用某某。.o,但在这种情况下没有这么简单的线索。错误显示如下:
ld "/Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Products/Debug/MacOS Cover.app/Contents/MacOS/MacOS Cover" normal x86_64
cd "/Users/Administrator/Desktop/MacOS Cover"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Products/Debug -F/Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Products/Debug -filelist "/Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Intermediates/MacOS Cover.build/Debug/MacOS Cover.build/Objects-normal/x86_64/MacOS Cover.LinkFileList" -mmacosx-version-min=10.6 -framework Cocoa -o "/Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Products/Debug/MacOS Cover.app/Contents/MacOS/MacOS Cover"
ld: duplicate symbol _required in /Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Intermediates/MacOS Cover.build/Debug/MacOS Cover.build/Objects-normal/x86_64/keypad.o and /Users/Administrator/Library/Developer/Xcode/DerivedData/MacOS_Cover-aemdqkcjvuomtjfhkycsyowsgisn/Build/Intermediates/MacOS Cover.build/Debug/MacOS Cover.build/Objects-normal/x86_64/setoutput.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Command /Developer/usr/bin/clang failed with exit code 1
我尝试丢弃所有派生的数据文件等(似乎在一秒钟后弹出)。如果有人可以帮助我解决此问题,我将不胜感激。
答案 0 :(得分:1)
这两个目标文件各自导出具有相同名称的符号(required
;下划线是编译器的构件)。根据您对这两者的确切要求,您可能需要:a)重命名一个或两个;或者或b)通常通过标记static
使一个或两个具有内部链接。
您很有可能认为只有一个这样的符号,因为您在两个源文件都包含的标头中声明了它。但是,您可能无意中在了标题中定义了符号,而不仅仅是声明了它。然后,在包含它的每个源文件中对其进行定义。您必须使用required
的声明/定义显示源代码,以及如何将其带入每个源文件。