I have tried to write some code for a proxy with winsock2 in VScode but can't seem to get it to compile. When i call g++ -std=c++17 -Wall -Wextra -lws2_32 proxy.cpp in the terminal it answers with:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0x5c): undefined reference
to `__imp_WSAStartup'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0x9a): undefined reference
to `__imp_socket'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0xd8): undefined reference
to `__imp_htons'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0x109): undefined reference to `__imp_bind'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld. to `__imp_listen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0x171): undefined reference to `__imp_accept'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MARTIN~1\AppData\Local\Temp\ccfDVlTW.o:proxy.cpp:(.text+0x1bb): undefined reference to `__imp_recv
i have both tried with the lws2_32 flag and #pragma comment(lib, "Ws2_32.lib") to link the library but it doesn't seem to work. These are my includes:
#include <sys/types.h>
#include <winsock2.h>
#include <ws2tcpip.h>
//#pragma comment(lib, "Ws2_32.lib")
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
Have anybody any clue? Search half the internet for a solution and cant find one.