944,084 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 485
  • C++ RSS
Oct 25th, 2009
0

Linker Errors..

Expand Post »
I am trying to make a 3D Engine using OpenGL, I've got all the model loading, 3D nodes, all that stuff done, but I get linker errors when I try to compile, it.. these are the errors:

------ Build started: Project: TheAlienEngine, Configuration: Debug Win32 ------
Compiling...
main.cpp
core.cpp
ae_3d.cpp
Generating Code...
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.cpp(33) : warning C4700: uninitialized local variable 'model' used
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.cpp(49) : warning C4700: uninitialized local variable 'node' used
Linking...
core.obj : error LNK2005: "struct options_t somecrazyoptions" (?somecrazyoptions@@3Uoptions_t@@A) already defined in main.obj
core.obj : error LNK2005: "struct node_t * _nodes" (?_nodes@@3PAUnode_t@@A) already defined in main.obj
ae_3d.obj : error LNK2005: "struct node_t * _nodes" (?_nodes@@3PAUnode_t@@A) already defined in main.obj
C:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\TheAlienEngine\Debug\TheAlienEngine.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\TheAlienEngine\TheAlienEngine\Debug\BuildLog.htm"
TheAlienEngine - 4 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have used include guards in all the header files and I have looked through the pre-processed file and I still couldn't find where those things are defined twice.. I've attached the code in a .zip file if you want to see.
Attached Files
File Type: zip TheAlienEngine_Code.zip (1.02 MB, 11 views)
Last edited by tomtetlaw; Oct 25th, 2009 at 7:34 am.
Similar Threads
Reputation Points: 9
Solved Threads: 5
Posting Pro
tomtetlaw is offline Offline
591 posts
since Sep 2008
Oct 25th, 2009
0
Re: Linker Errors..
Don't put data definitions in header files. Header guards will only ensure that only one copy exists in each source file in which it is included, but as you see you will get linker errors for multiple definitions. Put data and function definitions in source files.

Move the data definition to a single source file. If you want to allow access to this global data via the header file, extern it in the header.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: need help
Next Thread in C++ Forum Timeline: weird ascii character on cout and fout





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC