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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 to
recv@16'TCPSocket.o(.text+0x7af): In function
ZN10QTCPSocket5writeEPcii': C:/TCPSocket.cpp:103: undefined reference to
select@20'TCPSocket.o(.text+0x7eb):C:/TCPSocket.cpp:108: undefined reference to
__WSAFDIsSet@8' TCPSocket.o(.text+0x822):C:/TCPSocket.cpp:111: undefined reference to
send@16'TCPSocket.o(.text+0x893): In function
ZN10QTCPSocket7connectE10QIPAddressi': C:/TCPSocket.cpp:129: undefined reference to
htons@4'TCPSocket.o(.text+0x8c5):C:/TCPSocket.cpp:132: undefined reference to
connect@12' TCPSocket.o(.text+0x8da):C:/TCPSocket.cpp:158: undefined reference to
closesocket@4'TCPSocket.o(.text+0x93e): In function
ZN10QTCPSocket4initEv': C:/TCPSocket.cpp:172: undefined reference to
socket@12'TCPSocket.o(.text+0x9ee):C:/TCPSocket.cpp:179: undefined reference to
setsockopt@20' TCPSocket.o(.text+0xa23):C:/TCPSocket.cpp:181: undefined reference to
setsockopt@20'TCPSocket.o(.text+0xa56): In function
ZN10QTCPSocket5closeEv': C:/TCPSocket.cpp:193: undefined reference to
closesocket@4'Thank you in advance for the assistance.
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
Please add -lws2_32 to your linker options. =)
Kip
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.
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