trying to use winsock2

Started by
3 comments, last by CharlesNardella 12 years, 8 months ago
Hey i am trying to run a simple chat program in c++ and a keep getting this error. Can anyone tell me how to fix it?


1>------ Build started: Project: RTS, Configuration: Debug Win32 ------
1>Build started 8/8/2011 5:43:59 PM.
1>InitializeBuildStatus:
1> Touching "Debug\RTS.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1> Socket.cpp
1>c:\users\levi\desktop\game\testfolder\rts\socket.cpp(19): warning C4551: function call missing argument list
1> Generating Code...
1>Socket.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__send@16 referenced in function "public: bool __thiscall Socket::SendData(char *)" (?SendData@Socket@@QAE_NPAD@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "public: bool __thiscall Socket::ReceiveData(char *,int)" (?ReceiveData@Socket@@QAE_NPADH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function "public: void __thiscall Socket::CloseConnection(void)" (?CloseConnection@Socket@@QAEXXZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function "public: void __thiscall ServerSocket::Listen(void)" (?Listen@ServerSocket@@QAEXXZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>C:\Users\levi\Desktop\Game\TestFolder\RTS\Debug\RTS.exe : fatal error LNK1120: 11 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.97
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Advertisement
you need to include Ws2_32.lib in your project
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Link to Ws2_32.lib


Project->Properties (Alt+F7)
Select Linker from the left pane, then Input.
Paste Ws2_32.lib in Additional Dependencies, then try a build.
Thanks :D
If that is visual studio like it resembles, linking is as easy as ..
#pragma comment(lib,"ws2_32.lib")

I don't know if that will work on any other compiler/IDE's.

This topic is closed to new replies.

Advertisement