简体   繁体   中英

Compiling from Linux to Windows

I want to compile my program from linux to run on Windows as exe. I know how to do it with mingw64 etc. but real problem is Windows doesn't have libraries of code but linux has. How can i compile it?

#define <sys/socket.h>
#define <arpa/inet.h>
#define <netinet/in.h>
int main(){

//some codes etc.

}

You may use Windows Sockets 2 ( Winsock ) which is used for socket programming in Windows:

#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")

int main()
{
}
#ifdef __WIN32__
    #include <winsock2.h>
#else
    #include <sys/socket.h>
#endif

Why not try preprocessor macros?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM