Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Luvman79

Link Error with VC++ LNK2005

This topic is 5889 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

I''m getting the following error when Linking... Linking... initLights.obj : error LNK2005: "float * lightPositionB" (?lightPositionB@@3PAMA) already defined in main.obj initLights.obj : error LNK2005: "float * lightPositionG" (?lightPositionG@@3PAMA) already defined in main.obj initLights.obj : error LNK2005: "float * lightPositionR" (? Debug/Lighting.exe : fatal error LNK1120: 9 unresolved externals Error executing link.exe. along with 15 more saying the same thing for different variables I have the previous variables "DEFINED" in a header file. When it says it''s already defined in main.obj I get lost. I didnt'' define anything there. All I have are function calls, and those functions, in a seperate .cpp file use those variables. I''ve included all the .h files accordingly, by I can''t figure out this linker error. Help anyone? Keep On Smiling

Share this post


Link to post
Share on other sites
Advertisement
Your .h files aren''t compiled; .cpp files are. Therefore, if your variable definitions are in .h file which is included in two .cpp files, those definitions are compiled twice. Use extern in .h files and define variables in .cpp files. There''s a good article here on GameDev regarding this issue.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!