Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,958 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,600 people online right now. Registration is fast and FREE... Join Now!




Problem understanding linking error

 
Reply to this topicStart new topic

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

kaizoku0506
19 May, 2008 - 08:40 AM
Post #1

New D.I.C Head
*

Joined: 23 Apr, 2008
Posts: 7


My Contributions
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).

IPB Image
User is offlineProfile CardPM
+Quote Post

Cerolobo
RE: Problem Understanding Linking Error
19 May, 2008 - 08:57 AM
Post #2

D.I.C Regular
Group Icon

Joined: 5 Apr, 2008
Posts: 440



Thanked: 31 times
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Problem Understanding Linking Error
19 May, 2008 - 09:02 AM
Post #3

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,921



Thanked: 47 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
Thanks for helping out Cerolobo!
User is online!Profile CardPM
+Quote Post

kaizoku0506
RE: Problem Understanding Linking Error
19 May, 2008 - 09:08 AM
Post #4

New D.I.C Head
*

Joined: 23 Apr, 2008
Posts: 7


My Contributions
Thanks Cerolobo!
That did the trick! biggrin.gif Now if I could just read these text books faster and figure out how to make this game more interesting tongue.gif. Thanks for your help!

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:21AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month