Advertisement

New to MicroSoft C++, getting nutty errors.

Started by July 27, 2000 12:52 AM
11 comments, last by JwayneT 24 years, 4 months ago
Um, I just got Microsoft C++ 5.0 or VC++, whatever. Anyway, I''m using code from that I wrote under borland and I''m running into some problems. I''m getting linker errors, stating that the functions I wrote in my own header files are being defined numerious times in the obj files. The help said this was a common error, but I don''t have the slightest idea how to fix it. Any VC++ jockies who would help I would be in debt to. a.h{text-decoration:none;color:blue;};a.h:hover{text-decoration:underline;background:red;};

Snootchie Bootchies!

-=CF=-
a.h{text-decoration:none;color:blue;};a.h:hover{text-decoration:underline;background:red;};

Why is it called a hot water heater? Isn't it cold when it goes in the tank?

[email=jtaylor@gtemail.net" class="h]-=CF=-[/email]
well are you actualy defining it in the headers?
like ummm the body of the function is in the header?
if so take them out and put them in a c/cpp file...

Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
Advertisement
Try a

#ifndef __ANYTOKEN_
#define __ANYTOKEN_

// your code here

#endif // __ANYTOKEN_

in your files so if the token is already defined by the preprocessor (by earlier compilation), it will not compile them again..

Or just use a

#pragma once

at the top of every file
WOW!,
I was just about to post on the same thing. Im getting those same errors too. For example, I decided to write a gamma control fade. In main.cpp I declared a variable like this:

LPDIRECTDRAWGAMMACONTROL lpDDGammaControl = NULL;

I then wrote my fade routine in that same file and got it to work. After that I decided that I wanted this routine to be part of my utility library. So, I cut and pasted the variable to utility.h and made a function for the routine. There is no mention anywhere of that variable in main.cpp, but im getting the following two errors:

1) utility.obj : error LNK2005: "struct IDirectDrawGammaControl * lpDDGammaControl" (?lpDDGammaControl@@3PAUIDirectDrawGammaControl@@A) already defined in main.obj

2)Debug/jewels.exe : fatal error LNK1169: one or more multiply defined symbols found

how in the hell do you fix this? Ive tried throwing out all of the old .obj files then doing a rebuild all. It didnt work.

any advice?,
skitzo_smurf
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
uh...guys. This is really starting to get on my nerves. Does anyone have ANY advice? I dont care how stupid it sounds. I will try it. By the way, Im using MSVC++ 6.0

thank you,
skitzo_smurf

Edited by - skitzo_smurf on July 27, 2000 4:37:43 AM
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
skitzo_smurf, If you are including the variable in your header file, it will be defined in utility.cpp and main.cpp (hence the problem). If you don''t need it in main.cpp, or utility.h you should just put it in utility.cpp. If you need it in any of this, try defining it in the utility header with extern, and putting the actual definition (without extern) in utility.cpp
Advertisement
ok I see now! Thank you very much.

skitzo_smurf
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
Hum, skitzo, are you actually trying to program at 4:XX AM?
That could be another cause to many code problems...
haha yeah...EVERY NIGHT. I want my game out and I want it out bad. Im trying to beat the deadline for that puzzle game contest!

skitzo_smurf
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
Ok, good luck then!

This topic is closed to new replies.

Advertisement