Sign in to follow this  
pcxmac

Linking issues - "redefined"

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.

HTH


Chad

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"

~main~
{

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.

THIS IS A PROBLEM WITH SETTINGS AND LINKING ISSUES WITH CODEWARRIOR 9, not a code issue.

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

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