Jump to content
  • Advertisement
Sign in to follow this  

Linking issues - "redefined"

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

when ever I compile and include "winsock2.h" I get classes and structs which are redefined, If I uninclude the winsock2.h file, the functions of that header are undefined. would I be correct in assuming there is another winsock2.h file, but with out any functions somewhere in my link path? Its frustrating, because I am not including that file twice, and to boot If I dont include the winsock2.h file, the classes and structs dont return any errors even though I can't "find the reference" for them, maybe my linker looks for functions before classes, but still. ugh.

Share this post

Link to post
Share on other sites
What IDE are you using?

If VC++7 or above, try enabling "ShowIncludes" in the Advanced section of the project properties. That will show you which files are being included... natch.

If not, try searching for "winsock2.h" and search "Entire Solution" and/or all the include directories in your path. Find all the files where it is included, and see if you include THOSE headers.


It could also be that you are linking more than one static library where the symbols have been defined, and you have a linker error.



Share this post

Link to post
Share on other sites
yeah... to Alpha_ProgDes you listen :)

...and maybe do a clean build. It's possible some .obj (.o) and .lib (.a) files contain the same symbols.

Share this post

Link to post
Share on other sites
I have recompiled, rid my self of prior object code.

the code is quite simple, all I would have to do is

#include "winsock2.h"


anycall to a winsock function; /// errp function redefined.


error redefined - anycall

I have put this in an involved project, and a simple hello world program, same issues. Im quite put off with my linker right now.

Im almost certain its codewarrior specific. This is a conceptual problem, not a matter of syntax, and it has to do with my linker seeing double, where I have been only able to find one header file.


Share this post

Link to post
Share on other sites
Checking out these lines from winsock2.h...

#ifndef _WINSOCK2API_
#define _WINSOCK2API_
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */

...this suggests that maybe you're including <windows.h> before <winsock2.h>?

But I haven't looked through winsock2.h thoroughly... you may need <windows.h> first to define data types like DWORD and UINT.

[EDIT] woop ... look at this:

Lines 35-41:

* Pull in WINDOWS.H if necessary
#ifndef _INC_WINDOWS
#include <windows.h>
#endif /* _INC_WINDOWS */

Just do away with #include <windows.h>, if you have that in your header.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!