winsock linking problems
I am trying to get my head around windows sockets, however they are proving to be a lot more complex than in linux. So I decided to see just how much I would need to modify a simple echo client for linux to work in windows. I am using dev-c++ and I have changed all the parts of the program which I need to as far as I know. However, I still get errors about linking:
Now, I realised that my problem is probably me not linking the winsock library when compiler. So added "wsock32.lib" without quotes to tools->compiler options->compiler tab in the "Add these commands to the linker command line" box. The program compiles but fails to save the compiled copy, there are no compiler errors. It just claims the source file has not been compiled, and it is nowhere to be found in the specified folder. I'm pretty stumped, I thought that I might have forgot a command line switch in the linker box, but then it wouldn't work at all and I would still get the linker errors right?
[Linker error] undefined reference to `socket@12'
[Linker error] undefined reference to `htons@4'
[Linker error] undefined reference to `inet_addr@4'
[Linker error] undefined reference to `connect@12'
[Linker error] undefined reference to `send@16'
[Linker error] undefined reference to `recv@16'
ld returned 1 exit status
Thanks in advance,
Add "-lws2_32" (of course without quotes), not wsock32.lib if you have Dev-C++...
Add the winsock library to the link list. I dont have GCC handy at the moment, so im nto usre exactly where, but there is a spot to put in which files you want to add. Although under gcc I think the use the extension .A
Not linking the winsock library is definately the problem.