Archived

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

Sec-Gen

damn redefinitions

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
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
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
quote:

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.



1) Not rationalized.

2) That''s a problem with the programmer, not the method.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
Yeah, what''s the big idea with that?

On the one I started I have a salient point to make, not on the programming side, more on the issue that there even is an issue and the last few exchanges on this thread mirror my message at the end of my thread.

http://www.gamedev.net/community/forums/topic.asp?whichpage=2&pagesize=20&topic_id=85638

Share this post


Link to post
Share on other sites