Reputation: 35
I am trying to build and run a basic C program in Xcode, but keep getting a "build failed" message. The script is nothing too crazy, just a natural number calculator, there's nothing wrong with the script as I've tested it on an online compiler and it works fine.
This is the full error message:
Ld /Users/Matt/Library/Developer/Xcode/DerivedData/testing.c-ckojksceiqxrcdcfavsxvsgvapin
/Build/Products/Debug/testing.c normal x86_64
cd /Users/Matt/Code/testing.c
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/Matt/Library/Developer/Xcode/DerivedData/testing.c-
ckojksceiqxrcdcfavsxvsgvapin/Build/Products/Debug -F/Users/Matt/Library/Developer/Xcode/DerivedData
/testing.c-ckojksceiqxrcdcfavsxvsgvapin/Build/Products/Debug -filelist /Users/Matt/Library/Developer
/Xcode/DerivedData/testing.c-ckojksceiqxrcdcfavsxvsgvapin/Build/Intermediates/testing.c.build/Debug
/testing.c.build/Objects-normal/x86_64/testing.c.LinkFileList -mmacosx-version-min=10.9 -Xlinker
-dependency_info -Xlinker /Users/Matt/Library/Developer/Xcode/DerivedData/testing.c-
ckojksceiqxrcdcfavsxvsgvapin/Build/Intermediates/testing.c.build/Debug/testing.c.build/Objects-
normal/x86_64/testing.c_dependency_info.dat -o /Users/Matt/Library/Developer/Xcode/DerivedData
/testing.c-ckojksceiqxrcdcfavsxvsgvapin/Build/Products/Debug/testing.c
duplicate symbol _main in:
/Users/Matt/Library/Developer/Xcode/DerivedData/testing.c-ckojksceiqxrcdcfavsxvsgvapin/Build
/Intermediates/testing.c.build/Debug/testing.c.build/Objects-normal/x86_64/tests.o
/Users/Matt/Library/Developer/Xcode/DerivedData/testing.c-ckojksceiqxrcdcfavsxvsgvapin/Build
/Intermediates/testing.c.build/Debug/testing.c.build/Objects-normal/x86_64/main.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anybody know how to solve this? I've been searching for an answer for ages with no luck.
Upvotes: 1
Views: 1079
Reputation: 89509
You have two "main
" functions defined.
One in a file named "main.c
" and the other in a "tests.c
" file. Remove one of them and you should be okay!
Or, if you only have a "testing.c
" file, do a Clean on your xcode project and try building again.
Upvotes: 1