#1
  1. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    321
    Rep Power
    12

    Linkage/redifinition errors. Winsock2.h


    Ok, I kind of fixed it, I have a lot of headers/source files, the only errors I get now are errors for every winsock function. I do include winsock2.h in a lot of the headers, but I have directives that don't allow me to keep including the same file (#ifndef..#endif..etc). Where can the problem be?

    C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\WinSock2.h(2068): error C2375: 'socket' : redefinition; different linkage

    C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\WinSock2.h(2466): error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage
  2. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    in your main, you should first include winsock, then after it has been included you include all the files that need to use winsock. that way you only need to include it once. at least in gcc that is how i do it, someone please smack me if that's incorrect for MSVS.net
  4. #3
  5. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    321
    Rep Power
    12
    yeah but if I include it for every file, it shouldn't matter because _WINSOCK2_API_ is defined already, am I correct?

    I "fixed" the problem, for now. I compiled each file alone, and when I got to 1 file, it didn't compile, also whenever I tried to view this file in MSVC's IDE, it was viewing with the binary viewer, not ascii, I removed the file and reMade a new file from within mscv (I originally made the files using notepad), and pasted everything.

    Anyway that had nothing to do with the problem I think, I was including shellapi.h.. and after commenting this out, it worked. No warnings/errors. I don't know what's wrong with shellapi.h, I am linking shell32.lib..

IMN logo majestic logo threadwatch logo seochat tools logo