简体   繁体   English

使用Linux下的MinGW在Windows 7中交叉编译C和C ++应用程序

[英]Cross-Compiling C and C++ application in Windows 7, using MinGW under linux

I have installed MinGW compiler in Windows 7. GCC version is 4.6.1. 我已经在Windows 7中安装了MinGW编译器。GCC版本为4.6.1。

I have Hello World application: 我有Hello World应用程序:

#include <stdio.h>

int main( int argc, char* argv[] )
{
    printf( "Hello World!" );
    return 0;
}

How I can compile this application under Windows 7, using MinGW compiler, in order that i can run this application in linux, without recompile. 我如何使用MinGW编译器在Windows 7下编译此应用程序,以便可以在Linux中运行该应用程序而无需重新编译。

I don't think MinGW provides any cross-compilers that are able to produce linux binaries. 我认为MinGW不提供任何能够生成linux二进制文件的交叉编译器。

This can be done using Cygwin, they provide cross-compilers so that you can compile linux binaries on a Windows host. 这可以使用Cygwin完成,Cygwin提供了交叉编译器,因此您可以在Windows主机上编译linux二进制文件。 You just need to install the necessary packages. 您只需要安装必要的软件包。

You need to distinguish two systems here: The build system, which is the one your compiler runs on, and the host system, which is the one your executable will run on. 您需要在此处区分两个系统: 构建系统,即您的编译器在其上运行的系统;以及主机系统,即您的可执行文件将在其上运行的系统。 MinGW is the GCC compiler for the host system Windows. MinGW是主机系统Windows的GCC编译器。 So, you can compile on Windows for Windows or cross-compile on Linux for Windows. 因此,您可以在Windows的Windows上编译或在Linux的Windows上交叉编译。 You are looking for a cross compiler for build Windows to host linux, which might be included in Cygwin. 您正在寻找用于构建Windows的交叉编译器来承载linux,Cygwin中可能包含该交叉编译器。

However, generally such things are not well-supported, since Windows is normally used as an end-user only system, not for developing, and UNIX systems for developers. 但是,由于Windows通常仅用于最终用户系统(而不是用于开发),而UNIX系统通常用于开发人员,因此通常情况下,这种情况并不能得到很好的支持。 So, you are compiling against the stream here, something not too many people do. 因此,您在这里针对流进行编译,这不是太多人做的事情。

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

相关问题 从Linux到Windows交叉编译C ++应用程序的手册? - Manual for cross-compiling a C++ application from Linux to Windows? 在Linux机器上使用cmake Qt5 Webkit交叉编译并使用mingw定位Windows的C ++失败 - C++ cross-compiling using cmake Qt5 Webkit on a Linux box, targeting Windows using mingw, fails 在Linux上与MinGW交叉编译C ++代码,目标是Windows:发生错误 - Cross-compiling C++ code with MinGW on Linux, targetting Windows: error happens 在 linux 上使用 sdl 交叉编译 c++ - Cross-compiling c++ with sdl on linux 交叉编译beaglebone black的c ++ openCV应用程序时遇到问题 - Trouble with cross-compiling an c++ openCV application for the beaglebone black 在 Windows 上使用 MinGW 在 cmd 中编译 C++ 8 - Compiling C++ in cmd using MinGW on Windows 8 在Linux下使用distutils交叉编译python扩展 - Cross-compiling python extensions under Linux using distutils 使用 cmake 在 Linux for Windows 上交叉编译程序 - Cross-Compiling a program on Linux for Windows using cmake 从 Linux 交叉编译到 Windows 时,MinGW 无法链接指定的库 - MinGW cannot link libraries specified when cross-compiling from Linux to Windows 从Windows上的Visual Studio 2013交叉编译C ++ OpenCV至Ubuntu - Cross-compiling C++ OpenCV from Visual Studio 2013 on Windows to Ubuntu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM