简体   繁体   English

从Linux编译到Windows

[英]Compiling from Linux to Windows

I want to compile my program from linux to run on Windows as exe. 我想从linux编译程序,以便在Windows上以exe身份运行。 I know how to do it with mingw64 etc. but real problem is Windows doesn't have libraries of code but linux has. 我知道如何用mingw64等来做。但是真正的问题是Windows没有代码库,而Linux有。 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: 您可以使用Windows套接字2( Winsock ),该套接字用于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? 为什么不尝试预处理器宏?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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