Jump to content
  • Advertisement

Archived

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

Sec-Gen

damn redefinitions

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

How the hell do I get rid of an error like this? main.obj : error LNK2005: "class CAMERA camera_main" (?camera_main@@3VCAMERA@@A) already defined in input.obj What I''m trying to do is make a global variable. The problem is, if I want to make it truly global I have to put it in a header file and include it in all my source files that use it. Am I right?

Share this post


Link to post
Share on other sites
Advertisement
main.obj : error LNK2001: unresolved external symbol "class CAMERA camera_main" (?camera_main@@3VCAMERA@@A)

I just did "extern CAMERA camera_main;"

Share this post


Link to post
Share on other sites
It also helps to use defines ie:

#ifndef _MYFILE_H_
#define _MYFILE_H_

Lot''s o'' Code

#endif

Make sure you put that in each header file you have, but make the "_MYFILE_H_" part different for each file, otherwise you''ll have even more problems. The preprocessor takes care of that, and will make your code compile correctly.

Share this post


Link to post
Share on other sites
The

#ifndef _MYFILE_H_
#define _MYFILE_H_

thing didn''t work. I still get

ain.obj : error LNK2005: "class CAMERA camera_main" (?camera_main@@3VCAMERA@@A) already defined in input.obj

I''m going to researth this "extern" thing a bit though... it sounds familiar... and interesting.

Share this post


Link to post
Share on other sites
quote:
Original post by Sec-Gen
main.obj : error LNK2001: unresolved external symbol "class CAMERA camera_main" (?camera_main@@3VCAMERA@@A)

I just did "extern CAMERA camera_main;"


That is the first step. After you have the 'extern' keyword in your header, you need to have an actual instance of that object in ONE of your .CPP files. In other words, in one of your CPP files, put the line

CAMERA camera_main;

with no 'extern.'

EDIT: Typo

[edited by - jaxson on March 19, 2002 11:15:12 PM]

Share this post


Link to post
Share on other sites
Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh now I get it. Very much thanks to you.

extern is now my favorite word.

Share this post


Link to post
Share on other sites
Oh, well then, let us all bow down before the great OOP.

What I mean is, OOP is good, but it isn''t necessary at all times. Especialy in small programs and especialy if you don''t completely know how to use it.

extern lets me get past a problem I''ve been having for a long time.

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!