Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Hydrocity

macrumors 6502a
Original poster
May 14, 2010
527
0
Starting intro to C++ class and whenever I try adding an existing cpp file to my xcode project, I get this error when building. I have no coding experience, and would really appreciate any help!

Code:
Ld "/Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Products/Debug/testing" normal x86_64
    cd "/Volumes/Macintosh HD/Users/Ryan/Desktop/testing"
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    "/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" -arch x86_64 -isysroot "/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" "-L/Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Products/Debug" "-F/Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Products/Debug" -filelist "/Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Intermediates/testing.build/Debug/testing.build/Objects-normal/x86_64/testing.LinkFileList" -mmacosx-version-min=10.8 -stdlib=libc++ -o "/Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Products/Debug/testing"

duplicate symbol _main in:
    /Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Intermediates/testing.build/Debug/testing.build/Objects-normal/x86_64/main.o
    /Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Intermediates/testing.build/Debug/testing.build/Objects-normal/x86_64/Lab3_3_1.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Think I just solved my problem literally a min after posting. I deleted the default main cpp file that is included when making a new project and everything works now.
 
You have the main() function defined in two files. Copy the contents of Lab3_3_1.cpp into the main.cpp file (delete everything in main.cpp first) and then remove Lab3_3_1.cpp from the Xcode project and you should be good to go.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.