FotoguyOne-77

Q: Please help! Xcode linker error?

Hello! I am a Computer Science student, and I'm having problems with Xcode. I've looked all over the internet and can't seem to find any answers.

 

I recently created a new project in Xcode so I could work on one of my programming assignments. Just a couple weeks ago I programmed and completed a project (in C++) in Xcode with no problem. This time when I tried to compile my new project, it gave me the error "linker command failed with exit code 1 (use -v to see invocation)". What does that mean? How can I fix it so I can continue working on my code? At first I thought it was something wrong with Xcode on macOS Sierra, so I restored one of my El Capitan backups and tried again. However, the same "linker command failed" error showed up again. I haven't done anything different from my other projects- all I did was add a couple header files and copy some code (that I knew worked) into them.

 

If you need photos of my code or the error message, just let me know! Any help is GREATLY appreciated!

MacBook Pro with Retina display, OS X El Capitan (10.11.4)

Posted on Oct 6, 2016 9:16 PM

Close

Q: Please help! Xcode linker error?

  • All replies
  • Helpful answers

  • by Mark Szymczyk,

    Mark Szymczyk Mark Szymczyk Oct 7, 2016 7:41 PM in response to FotoguyOne-77
    Level 4 (2,009 points)
    Oct 7, 2016 7:41 PM in response to FotoguyOne-77

    You need to provide a lot more information for anyone to help you. You say all you did was add a couple of header files and copy some code into them. What were the header files? What was the code you copied? Don't post a picture of the code. It will be too hard to read the code from a picture. Copy the text. You should also click the HTML button in the post editor to format your code to make it readable. Wrap your code in <code> tags.

     

    The error "linker command failed with exit code 1" could mean many things. You need to provide a more specific error message. In  Xcode choose View > Navigators > Show Report Navigator to show the report navigator. There should be a Build step in the report navigator with an error icon next to it. Select the Build step to see the steps Xcode took to build the project. There will be a step with an error and a more detailed error message. You need to provide that detailed error message for anyone to be able to help you.

  • by FotoguyOne-77,

    FotoguyOne-77 FotoguyOne-77 Oct 7, 2016 8:36 PM in response to Mark Szymczyk
    Level 1 (8 points)
    Notebooks
    Oct 7, 2016 8:36 PM in response to Mark Szymczyk

    Hello Mark- thank you so much for being willing to help! I actually figured out the problem earlier today. For whatever reason, I accidentally #included both the .h file AND the .cpp file for a class in my main function, and Xcode crashed because there were multiple declarations of the same things (the functions and variables in my class). Thanks for the help though, and I'll be sure to do what you said about giving more information and posting my code as text next time I ask a question on the forums.

  • by etresoft,

    etresoft etresoft Oct 7, 2016 8:53 PM in response to FotoguyOne-77
    Level 7 (29,345 points)
    Mac OS X
    Oct 7, 2016 8:53 PM in response to FotoguyOne-77

    FotoguyOne-77 wrote:

     

    If you need photos of my code or the error message, just let me know!

    Hello FotoguyOne-77,

    That would be the best place to start.