As @Joshua commented, you probably want ws2_32.dll
.
The GNU Compiler Collection uses ranlib archives (A files) rather than Visual Studio LIB files.
The w32headers project provides gcc
- and g++
-compatible headers and archives for most standard Windows DLLs, including ws2_32.dll
. The name of the archive is usually the name of the DLL minus the .dll
extension, prefixed with lib
and suffixed with .a
(following the *nix archive naming convention). Thus, the symbols for ws2_32.dll
are in libws2_32.a
, which can be linked with using ‑lws2_32
.
By default, the w32headers archives are in the GNU ld
library path, so to be able to link with standard Windows DLLs, there is no need to add library directories with an ‑L
option. In your case, the only option that you need is ‑lws2_32
:
g++ C:\Program.cpp -lws2_32
Assuming that compilation and linking succeed, the output will be a.exe
in the current directory. You can override the name of the output binary with the ‑o
option.
NOTE: I used non-breaking hyphens in my answer. If you copy & paste the command line options, be sure to replace all hyphen-looking characters with regular hyphens.