Author | Message | Time |
---|---|---|
TheNewOne | Ok on other compilers I have no problem with this but im getting a linked error and im looking for some insight. [code] Linking... Project1.obj : error LNK2001: unresolved external symbol _connect@12 project1.obj : error LNK2001: unresolved external symbol _htons@4 project1.obj : error LNK2001: unresolved external symbol _gethostbyname@4 project1.obj : error LNK2001: unresolved external symbol _socket@12 project1.obj : error LNK2001: unresolved external symbol _WSAStartup@8 project1.obj : error LNK2001: unresolved external symbol _closesocket@4 project1.obj : error LNK2001: unresolved external symbol _send@16 Debug/project1.exe : fatal error LNK1120: 7 unresolved externals Error executing link.exe. [/code] My Code is at work this is all i can provide sorry for the inconvience. p.s. IT seems to give me the same error if i include winsock2.h or not so thats what confuses me. | September 7, 2005, 1:50 AM |
Kp | You must also direct the compiler to link in the WinSock library. Unlike on proper Unix systems, socket support is not in the default library. If you were using MinGW, I'd tell you to add -lws2_32 to the command line. Microsoft's linker syntax is wrong though, so that won't work for you. Look around in the "Linker input" section of your project. Find a list of libraries (ought to see kernel32.lib, user32.lib, gdi32.lib, etc. in there) Add " ws2_32.lib" at the end of the list and your project should work fine. | September 7, 2005, 2:14 AM |
R.a.B.B.i.T | Project > Settings : "Link" Tab Add "ws2_32.lib" to the end of the box under "Object/[u]l[/u]ibrary modules" MSVC++, of course. | September 7, 2005, 3:19 AM |
Kp | Sure, if you're still using something outdated like VC6. :) VC7 has a completely different way of specifying it, which is why I gave him vague version-independent guidance. | September 7, 2005, 3:59 AM |
K | Whenever I'm working in a Visual Studio environment, my favorite way to link to a library is: [code] #pragma comment(lib, "ws2_32"); [/code] Becuase I don't have to leave the source file. | September 7, 2005, 6:57 AM |