Server Help

General Questions - Errors in C++!

Versetti - Thu Mar 04, 2004 9:40 pm
Post subject: Errors in C++!
These errors I got in the past alot and nver knew how to fix and it is ticking me off! here is what it says

Code: Show/Hide
--------------------Configuration: Server - Win32 Debug--------------------
Compiling...
packets.cpp
Linking...
packets.obj : error LNK2005: "int mainid" (?mainid@@3HA) already defined in main.obj
packets.obj : error LNK2005: "unsigned char * recvmsg" (?recvmsg@@3PAEA) already defined in main.obj
packets.obj : error LNK2005: "struct players * player" (?player@@3PAUplayers@@A) already defined in main.obj
Debug/Server.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

Server.exe - 4 error(s), 0 warning(s)


and the files I have is two .cpp files and two .h file.

would anyone know how the hell I can fix this?
Mr Ekted - Thu Mar 04, 2004 10:03 pm
Post subject:
My guess is that you are defining those things in a header file rather than declaring them, so each .cpp file has its own copy of the data.

A header file should only declare data like:

extern int xyz;

A single source file in your project should declare that data like:

int xyz;

If this is not your problem, post all 4 of your files and I'll take a closer look.
Anonymous - Mon Mar 08, 2004 1:01 pm
Post subject:
Grrrrrrr I'm going to learn more with linked lists and rewrite the whole danm thing getting tired of that error, and yes I tried to delcare them as extern and still the same danm error icon_sad.gif .
Mr Ekted - Mon Mar 08, 2004 2:23 pm
Post subject:
Post your code. Don't change things just because you get an error you don't understand. Learn why you are getting the error. Learnm what the error means. It will save you lots of trouble in the future.

If you 'd prefer to send me the code outside of this chat, we can talk over email or ICQ.
Versetti - Mon Mar 08, 2004 3:57 pm
Post subject:
Ok if you suggest to talk me on ICQ it is 313030930
I'm just getting pissed from these linked lists
Anonymous - Tue Mar 09, 2004 9:12 am
Post subject:
I kinda got it now just for the UDP sockets and how to organize the players and stuff
Mr Ekted - Tue Mar 09, 2004 10:18 am
Post subject:
Versetti wrote:
I'm just getting pissed from these linked lists


Describe what you are using LL for, and I can discuss it. What LL functions do you need? Insert at head/tail/random? Delete head/tail/random? Sort? Find?
Anonymous - Tue Mar 09, 2004 1:52 pm
Post subject:
What I really need is a nicely done tutroial on how to make linked lists and their funcation. I really only made one linked list but it was not all that great.
Cyan~Fire - Tue Mar 09, 2004 4:08 pm
Post subject:
*hypnotizes versetti* Use STL lists, use STL lists...
Mr Ekted - Tue Mar 09, 2004 4:32 pm
Post subject:
*hypnotizes cyan~fire* gay...gay...
Cyan~Fire - Tue Mar 09, 2004 4:37 pm
Post subject:
Lol. I know they're bad, but it's better than trying to make one yourself.
Mr Ekted - Tue Mar 09, 2004 4:42 pm
Post subject:
Linked lists are tiny and easy to code. It's better to learn them than to always rely on some wrapper. That way if you are having a problem you can debug with intelligence. People that rely on classes to do all their work for them grow up to write crappy code.
Versetti - Tue Mar 09, 2004 8:03 pm
Post subject:
yes I agree I'm not too much with using wrappers since they are really just others work. Like UDP Sockets I'm making my own while others suggest me to use wrappers and stuff. But I really need to learn linked lists so I have to try something to help me that is ez to understand.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group