在cygwin下使用GCC生成的可执行文件 [英] Executable file generated using GCC under cygwin

查看:654
本文介绍了在cygwin下使用GCC生成的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Cygwin和GCC(版本4.3.4 20090804(发布)1)安装为Cygwin包。

I am using Cygwin and have GCC (version 4.3.4 20090804 (release) 1 ) installed as Cygwin package.

当我使用GCC在Cygwin下构建C代码shell,生成的可执行输出文件是一个类型的可执行文件(PE32可执行为MS Windows(控制台)Intel 80386 32位),它只能在Cygwin shell下执行/运行,而不是作为独立的.exe在Windows shell /命令提示符。如果我试图在Windows命令提示符下单独运行它,它会给出一个错误窗口该程序无法运行,因为cygwin.dll从您的计算机丢失。

When I built C code using GCC under Cygwin shell, the generated executable output file is a executable of type (PE32 executable for MS Windows (console) Intel 80386 32-bit) and it can only be executed/run under Cygwin shell, not as standalone .exe on Windows shell/command prompt. If I try to run it standalone on Windows command prompt it gives an error window saying "The program can't run because cygwin.dll is missing from your computer".


  1. 如何使这个.exe独立,可以在任何其他系统的命令提示符下执行,甚至可以在我自己的系统中执行?

  1. How can one make this .exe standalone, which can be executed on a command prompt of any other system or even in my own system?

我认为Cygwin下的GCC会构建一个Linux可执行文件(ELF 32位LSB可执行文件),但并不是这样。如何使用gcc-cygwin组合生成一个* .out类型的Linux可执行文件?

I thought GCC under Cygwin would build a Linux executable (ELF 32-bit LSB executable), but it's not so. How can I use the gcc-cygwin combination to generate a *.out kind of Linux executable file?

此外,我无法运行在Linux-gcc组合上生成的Linux可执行文件,无法在Cygwin下执行。

Also, I cannot run a Linux executable generated on a Linux-gcc combination to execute under Cygwin.

任何指针都会有所帮助。

Any pointers would be helpful.

推荐答案

Cygwin不是Linux仿真器,即它不生产或运行Linux可执行文件。因此,你需要一个虚拟机或coLinux。

Despite widespread rumours, Cygwin is not a Linux emulator, i.e. it doesn't produce or run Linux executables. For that you'll need a virtual machine or coLinux.

相反,Cygwin是一个兼容层,旨在尽可能实现POSIX和Linux API视窗。这意味着程序必须专门为Cygwin编译,但它也意味着它更好地与Windows集成。它允许您在同一程序中混合使用POSIX和Windows API。

Instead, Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin, but it also means that it's better integrated with Windows, e.g. it lets you mix POSIX and Windows APIs in the same program.

这是cygwin1.dll提供的兼容性层。如果使用gcc-3的-mno-cygwin开关或一个MinGW编译器来构建非Cygwin可执行文件,则当然不能使用任何POSIX / Linux特定的API,任何这样的调用都需要用Windows

It's the cygwin1.dll that provides that compatibility layer. If you build non-Cygwin executables using gcc-3's -mno-cygwin switch or one of the MinGW compilers, then of course you can't use any POSIX/Linux-specific APIs, and any such calls will need to be replaced with Windows equivalents.

这篇关于在cygwin下使用GCC生成的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆