0

I try to build some C++ code in OMNeT++ (Eclipse) however I get some compiler error:

Creating executable: out/gcc-release//TCP.exe
C:/Users/Omnet++/omnetpp-5.6.2/tools/win64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lWs2tcpip
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:95: out/gcc-release//TCP.exe] Error 1
"make MODE=release all" terminated with exit code 2. Build might be incomplete.

I'm not sure what "lWs2tcpip" is, but I have included the path to "ws2tcpip.h" in my includes folder. Anyway, it does not seem to work. (Included: C:\Users\Omnet++\omnetpp-5.6.2\tools\win64\mingw64\x86_64-w64-mingw32\include -**written with both "/" and "" to exclude this as an error ** )

Looking for what lws2tcpip might be I only find a "lws2tcpip.pp" file here: http://git.ccs-baumann.de/Martok/lnet-bitspace/blob/master/lib/lws2tcpip.pp

But I don't really think I need it.

My program compiles perfectly in Visual Studio, so I think it's a compiler thing in this Eclipse/Omnet++ setup.

Additonal info: In my program I only include these rather basic libs / .h files for my tcp handling:

#include <iostream>
#include <string>
#include <winsock2.h>
#include <ws2tcpip.h>

Maybe anybody has an idea how I can solve this likely compiler-driven problem. Best regards, LP

Jerzy D.
  • 6,707
  • 2
  • 16
  • 22
  • 2
    What if you link with `-lWs2_32` instead of `-lWs2tcpip`? `ws2tcpip.h` is the header, `Ws2_32` is the library. – Ted Lyngmo Apr 25 '22 at 21:18
  • `-l` tells the linker to link in the named library. [This goes on after the program is compiled](https://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work). – user4581301 Apr 25 '22 at 21:23

0 Answers0