cygwin - 不能执行二进制文件 [英] cygwin - cannot execute binary file

查看:3573
本文介绍了cygwin - 不能执行二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行这两个.data文件从我的c ++代码为我的任务。我已经提供了所有的文件,并且只是为程序实现一些功能(一切都应该能够编译运行make命令)。

I am trying to run these two .data files from my c++ code for my assignment. I have been provided with all the files and are meant to only implement a few functions for the program (everything should be able to compile running the make command).

我使用运行一个MAC,只是刚刚开始使用windows(win 7),因为工作给了我一个免费的笔记本电脑。反正...我安装cygwin,添加了gcc-c ++编译器,gdb和make包我的cygwin。但是当我运行命令 ./ file ./data 时会出现:

I used to run a MAC and only just started using windows (win 7) because work gave me a free laptop. Anyways...I installed cygwin, added the gcc-c++ compiler, gdb and make packages to my cygwin. But when i run the command ./file ./data it comes up with:

bash: ./file: cannot execute binary file

我想安装?请注意,./data是保存我的两个.data文件的文件夹, file1.data file2.data

is there a certain package or something I am suppose to install? Please note, that ./data is the folder that holds my two .data files, file1.data and file2.data

g++ -Wall -Werror -02 -c file.cpp
g++ -Wall -Werror -02 -c file-test.cpp
g++ -Wall -Werror -02 -o file file.o file-test.o


推荐答案

使用文件开始命令查看你有什么类型的二进制文件:

Start by using the file command to see what type of binary file you have:

file ./file

如果它不是可执行文件,那就是一个问题。如果它是一个ELF可执行文件,那么它可能是打算在Linux上运行, Windows。例如,比较输出与此命令:

If it is not an executable, that is a problem. If it is an ELF executable then it is probably intended to run on Linux, not on Windows. For example compare the output with this command:

file /bin/bash

它应该告诉你:

/ bin / bash:PE32可执行文件80386(剥离到外部PDB),用于MS Windows

/bin/bash: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows

现在请尝试此命令:

file /cygdrive/c/windows/write.exe


/cygdrive/c/windows/write.exe:PE32 +可执行文件(GUI)x86-64,用于MS Windows

Which says the following: /cygdrive/c/windows/write.exe: PE32+ executable (GUI) x86-64, for MS Windows

我在64位Windows 7安装,这就是为什么它说x86-64。即使这是一个完全与cygwin无关的Windows GUI应用程序,我仍然可以通过命令运行它:

I ran this on a 64-bit Windows 7 installation, which is why it says x86-64. Even though this is a Windows GUI app totally unrelated to cygwin, I can still run it by the command:

/cygdrive/c/windows/write



你真的没有解释如何得到这个二进制文件名为 ./ file 。有可能它是一个目标文件从编译,你还没有链接到一个可执行文件。如果你有一个Makefile,为什么不发布其内容?

You really did not explain how you got this binary file named ./file. Is it possible that it is an object file from compiling that you have not yet linked into an executable? If you have a Makefile, why not post its contents?

这篇关于cygwin - 不能执行二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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