Problem understanding linking error

Xcode returned a linking error, but I can't figure out how to fix

Page 1 of 1

3 Replies - 804 Views - Last Post: 19 May 2008 - 10:08 AM Rate Topic: -----

#1 kaizoku0506  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-April 08

Problem understanding linking error

Posted 19 May 2008 - 09:40 AM

I wrote a VERY basic game in C++ as an exercise. However, after my last set of updates, XCode started returning a linking error. I can't figure it out to save my life. I've attached a screenshot of the error message. It references three completely unrelated pieces of code. I don't know what it means. Any help would be very much appreciated!

(The error message is displayed twice. Once in red, and again below highlighted in gray).

Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: Problem understanding linking error

#2 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Problem understanding linking error

Posted 19 May 2008 - 09:57 AM

It means that you are compiling the same function more then once.

This generally happens when you have the actual function body inside a header file, and you include the header more then once. This is a linker error, since there are two functions that are completely different (in the linker's eyes), yet they have the same exact signature, so the linker does not know which one to choose.

If you implemented the body of the function in the header, just move it to the .cpp.
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Problem understanding linking error

Posted 19 May 2008 - 10:02 AM

Thanks for helping out Cerolobo!
Was This Post Helpful? 0
  • +
  • -

#4 kaizoku0506  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-April 08

Re: Problem understanding linking error

Posted 19 May 2008 - 10:08 AM

Thanks Cerolobo!
That did the trick! :D Now if I could just read these text books faster and figure out how to make this game more interesting :P. Thanks for your help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1