| | |
Linker Errors..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
------ 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.
Last edited by tomtetlaw; Oct 25th, 2009 at 7:34 am.
...
0
#2 Oct 25th, 2009
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.
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- linker errors... I HATE THEM (C++)
- class templates -linker errors (C++)
- Linker errors using HWND (C++)
- Linker Errors (C++)
- Linker Errors (C++)
- Linker Errors (C++)
- Dev C++ linker errors, undefined reference (C++)
- DEV-C++ linker errors (C++)
Other Threads in the C++ Forum
- Previous Thread: need help
- Next Thread: weird ascii character on cout and fout
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






