Sign in to follow this  

Microsoft Visual Studio .NET Release Build

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

Hello, I just got my student version of the aforementioned program in the mail the other day and I decided to write a quick tron clone to play around with it. Before now all I've ever used were some of the various linux IDEs, and I can already say I absolutly love it. Anyway, I wrote my tron clone and everything worked wonderfully when I compiled it in debug mode. Then I wanted to switch it over to a Release build to see what the difference was. Now everytime I try to build I get "error LNK2005 blah blah player::crash(void) (?crash@player@@QAEXXZ)) already defined in player .obj." I tried to delete all of the .obj files (also tried the Clean Solution option) and rebuild, but it gets the same error again. I tried looking around in google for a bit but I couldn't find anything. Anyone here able to shine some light on the situtation. Thanks for your time.

Share this post


Link to post
Share on other sites
> first things first - check yor build log, see what the linker is linking.
> from the description of the error it is trying to define something in two obj files, find out which ones (the obj files are directly generated from your cpp files) and stop both from being linked, (check your code for duplicates of the class)

Share this post


Link to post
Share on other sites
Well that's weird. I checked the buildlog and it seemed that everything was in order (it did work in debug mode after all). So I thought about it for a bit and decided to try copying everything from my player.cpp to my player.h file. This fixed it.

I've never had any problems like this when programming in linux. I've heard that MVS .NET doesn't follow the C++ standards. Is there a certain way you're supposed to set up classes in MVS .NET

here's a glimpse of how I did it

in player.h:

class player
{
public:
int getTrivialData() {return data;}
void bigUglyFunction();
private:
int data;
};

in player.cpp:

#include "player.h"

void player::bigUglyFunction()
{
// code
}




Is this wrong?

Share this post


Link to post
Share on other sites
You did have include guards in the .h file, right?
ie

//player.h
#ifndef PLAYER_H
#define PLAYER_H

class player
{
public:
int getTrivialData() {return data;}
void bigUglyFunction();
private:
int data;
};

#endif



Share this post


Link to post
Share on other sites
Yes, I just forgot to put them in my example. Sorry about that.

Though, now I'm more confused. I just opened up a new solution and did the same thing as I orinigally had and it worked right off the bat. I'll have to go through all of the settings later and see if I changed anything. I did go through all of the settings and changed a bunch of stuff when I first started, I probably forgot to change something back. Probably not a good idea to start programming in the same project and expect everything to work as usual =)

Thanks for your time. I'll let you know later tonight if I find what I changed.

Share this post


Link to post
Share on other sites

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