Sign in to follow this  

general linker errors

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i use visual c++ 6.0. is not a spesific question about a library. i would like to know why an error accours like this: Linking... sample1.obj : error LNK2005: "void __cdecl display(void)" (?display@@YAXXZ) already defined in sample3.obj sample1.obj : error LNK2005: _main already defined in sample3.obj sample1.obj : error LNK2005: "class Particle p1" (?p1@@3VParticle@@A) already defined in sample3.obj init.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI_Master_Object::set_glutIdleFunc(void (__cdecl*)(void))" (?set_glutIdleFunc@GLUI_Master_Object@@QAEXP6AXXZ@Z) init.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI_Rotation::reset(void)" (?reset@GLUI_Rotation@@QAEXXZ) init.obj : error LNK2001: unresolved external symbol "public: class GLUI_Rotation * __thiscall GLUI::add_rotation(char *,float *,int,void (__cdecl*)(int))" (?add_rotation@GLUI@@QAEPAVGLUI_Rotation@@PADPAMHP6AXH@Z@Z) init.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI::set_main_gfx_window(int)" (?set_main_gfx_window@GLUI@@QAEXH@Z) init.obj : error LNK2001: unresolved external symbol "public: class GLUI * __thiscall GLUI_Master_Object::create_glui(char *,long,int,int)" (?create_glui@GLUI_Master_Object@@QAEPAVGLUI@@PADJHH@Z) init.obj : error LNK2001: unresolved external symbol "class GLUI_Master_Object GLUI_Master" (?GLUI_Master@@3VGLUI_Master_Object@@A) Release/sample3.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. sample3.exe - 10 error(s), 0 warning(s) lots of programs that i downloaded, says errors like these, the codes(*.cpp, *.h ...) do not give errors but when linking, complier says lots of errors that i cant solve by coding. i added the libraries to project. and the most interesting thing if i move project to new one, i mean if i make new project with same files and make same settings(adding .lib files); it complies! what can be the problems about linker? i would like to know more about linker. are there any other settings? are there any tutorial about general linker problems? Thank you.... *sorry for bad english..

Share this post


Link to post
Share on other sites
sample1.obj : error LNK2005: "void __cdecl display(void)" (?display@@YAXXZ) already defined in sample3.obj
sample1.obj : error LNK2005: _main already defined in sample3.obj
sample1.obj : error LNK2005: "class Particle p1" (?p1@@3VParticle@@A) already defined in sample3.obj


It seems like you have multiple versions of your main function (Particle, display), so when linking your object files together the linker cannot decide which one is the starting point of your application.

Did you write the code for the functions into the header ?
Did you try to link both examples together ?


nit.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI_Master_Object::set_glutIdleFunc(void (__cdecl*)(void))" (?set_glutIdleFunc@GLUI_Master_Object@@QAEXP6AXXZ@Z)
init.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI_Rotation::reset(void)" (?reset@GLUI_Rotation@@QAEXXZ)
init.obj : error LNK2001: unresolved external symbol "public: class GLUI_Rotation * __thiscall GLUI::add_rotation(char *,float *,int,void (__cdecl*)(int))" (?add_rotation@GLUI@@QAEPAVGLUI_Rotation@@PADPAMHP6AXH@Z@Z)
init.obj : error LNK2001: unresolved external symbol "public: void __thiscall GLUI::set_main_gfx_window(int)" (?set_main_gfx_window@GLUI@@QAEXH@Z)
init.obj : error LNK2001: unresolved external symbol "public: class GLUI * __thiscall GLUI_Master_Object::create_glui(char *,long,int,int)" (?create_glui@GLUI_Master_Object@@QAEPAVGLUI@@PADJHH@Z)
init.obj : error LNK2001: unresolved external symbol "class GLUI_Master_Object GLUI_Master" (?GLUI_Master@@3VGLUI_Master_Object@@A)


Seems you are missing some object files (maybe GLUI_Master_Object.obj) which the linker needs to resolve the references to those functions.


edit:
Seee here to learn something about the gnu linker. Maybe that helps in understanding what a linker really is and does.

Share this post


Link to post
Share on other sites

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this