Menu

windows socket programming

seifumng
2005-07-11
2012-09-26
  • seifumng

    seifumng - 2005-07-11

    I am using gcc 3.4.2 in windows XP environment. I am trying to create a DLL that uses sockets. The individual codes get compiled successfully. When I try to make a build, I get the following error
    messages. I wondered if anyone can help me in getting a solution for this problem.

    By the way, I also tried to include C:\WINNT\wsock32.dll in the build process.

    TCPSocket.o(.text+0x6b7):C:/TCPSocket.cpp:90: undefined reference to __WSAFDIsSet@8' TCPSocket.o(.text+0x6ee):C:/TCPSocket.cpp:92: undefined reference torecv@16'
    TCPSocket.o(.text+0x7af): In function ZN10QTCPSocket5writeEPcii': C:/TCPSocket.cpp:103: undefined reference toselect@20'
    TCPSocket.o(.text+0x7eb):C:/TCPSocket.cpp:108: undefined reference to __WSAFDIsSet@8' TCPSocket.o(.text+0x822):C:/TCPSocket.cpp:111: undefined reference tosend@16'
    TCPSocket.o(.text+0x893): In function ZN10QTCPSocket7connectE10QIPAddressi': C:/TCPSocket.cpp:129: undefined reference tohtons@4'
    TCPSocket.o(.text+0x8c5):C:/TCPSocket.cpp:132: undefined reference to connect@12' TCPSocket.o(.text+0x8da):C:/TCPSocket.cpp:158: undefined reference toclosesocket@4'
    TCPSocket.o(.text+0x93e): In function ZN10QTCPSocket4initEv': C:/TCPSocket.cpp:172: undefined reference tosocket@12'
    TCPSocket.o(.text+0x9ee):C:/TCPSocket.cpp:179: undefined reference to setsockopt@20' TCPSocket.o(.text+0xa23):C:/TCPSocket.cpp:181: undefined reference tosetsockopt@20'
    TCPSocket.o(.text+0xa56): In function ZN10QTCPSocket5closeEv': C:/TCPSocket.cpp:193: undefined reference toclosesocket@4'

    Thank you in advance for the assistance.

     
    • Kip

      Kip - 2005-07-12

      It tells the linker to link the libws2_32.a library against your executable. This is where the import declarations reside for the winsock 2 library. The actual code sits in various places in system drivers and dlls.

      Kip

       
    • Kip

      Kip - 2005-07-11

      Please add -lws2_32 to your linker options. =)

      Kip

       
    • seifumng

      seifumng - 2005-07-11

      Thanks Kip. It worked fine.

      It would have been a great help if you could tell me the meaning of the option you told me to include or advise me a document to refer for further reading ?

      Thanks again.

       
    • Nobody/Anonymous

      it's nothing magic, a good start to check out functions and their needed libraries should be here:

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_reference.asp

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.