Help with xcode (cpp file wont build)

Discussion in 'Mac Programming' started by Hydrocity, Oct 4, 2012.

  1. Hydrocity macrumors 6502a

    May 14, 2010
    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!

    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/" -arch x86_64 -isysroot "/Volumes/Macintosh HD/Applications/" "-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/" -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/
        /Volumes/Macintosh HD/Users/Ryan/Library/Developer/Xcode/DerivedData/testing-eydhxyuolbhrdqhjjmhkhxoskrub/Build/Intermediates/
    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.
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    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.

Share This Page