如何阻止Cygwin下的gcc添加".exe"?编译可执行文件? [英] How can I stop gcc under Cygwin from adding ".exe" to compiled executables?

查看:49
本文介绍了如何阻止Cygwin下的gcc添加".exe"?编译可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何防止Cygwin下的gcc自动将.exe扩展名添加到已编译文件中,因为我只是对丢失文件"造成了很多困惑.就上下文而言,我正在大学的C项目中工作,通常在运行Ubuntu(与Windows双重启动)的实验室中工作,但是要在家工作,我更喜欢使用Windows机器ergo Cygwin.如果我只是删除扩展名,那么它在任何一个系统上都仍然可以正常工作,但是每次我在Cygwin下编译扩展名时都必须更改命令以包含扩展名,这实在令人沮丧.

I would like to know how I can prevent gcc under Cygwin from automatically adding the .exe extension to compiled files, because I just caused myself a lot of confusion with "missing files". For context, I am working on a C project for university and I usually work in the labs which run Ubuntu (dual-boot with Windows), but to work from home I prefer using my Windows machine, ergo Cygwin. If I just remove the extension it still works just fine on either system, but it is rather frustrating to have to change the command to include the extension whenever I've just compiled it under Cygwin.

我从Cygwin查阅了FAQ,发现它可能与.bashrc或.bash_profile(

I looked up the FAQ from Cygwin to find that it is probably an issue related to an environment variable in .bashrc or .bash_profile (see here), but I am no command-line ninja and am not very familiar with editing configuration files... I found two related questions as well that show the same behaviour, but have nothing to do with trying to change it:

使用gcc进行编译(在Windows上为Cygwin)

在cygwin下使用gcc生成的可执行文件

有什么想法吗?

它实际上是针对C项目中的MPI的,所以我有一个调用mpicc的Makefile,但这与问题并没有真正的关系,因为我也尝试使用gcc,而且两者都做同样的事情.出于这个问题的目的,我得到的命令和输出是:

It is actually for an MPI in C project so I have a Makefile that calls mpicc but that is not really relevant to the problem, since I just tried with gcc as well and both do the same thing. For the purpose of this question, the commands and outputs I get are:

$ gcc -o hello hello.c
$ ls
hello.c    hello.exe
$./hello
Hello, world!
$./hello.exe
Hello, world!

请注意,无论有无扩展名运行,它在Shell中的作用都是一样的,但在mpirun中却没有,这就是为什么我要更改此行为的原因.

Note that running with or without the extension does the same thing in the shell, but it does not with mpirun which is why I want to change this behaviour.

我最终决定Windows不是适合我的编程环境.从现在开始,将可以在Linux中完成所有工作.

I eventually decided that Windows is not the programming environment for me. From now on all work that can be done in Linux will be.

推荐答案

存在可执行文件的自动exe扩展是有原因的(Windows要求).您应该自己弄混(也可以教育:-),并接受Cygwin的工作方式.这项功能植根于Cygwin/Windows胆囊,以至于几乎没有它就无法运行.

The automatic exe extension for executables is there for a reason (Windows requires it). You should deconfuse (aka educate :-) yourself and accept the way Cygwin works. This is a feature rooted so deeply in the Cygwin/Windows guts that it is almost impossible to make it run without it.

对于采用其他方法的"Windows上的Unix感觉",您想查看 AT& T的UWin .

For a "Unix feeling on Windows" with a different approach you want to check out AT&T's UWin.

这篇关于如何阻止Cygwin下的gcc添加".exe"?编译可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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