Меню Рубрики

Mac os cannot execute binary file

How to solve: -bash: : cannot execute binary file

I have a file named b1 that contains assembly language. I am trying to execute the file on OSX using

I get the following error:

I’ve looked at other similar questions, but to no avail. I’m definitely using a 64 bit architecture.

Here are output of relevant info:

Ran as b1 which ended up terminating with: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as: fatal error in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as

2 Answers 2

Sorry, this file is for GNU/Linux

According to your file output, this program is for GNU/Linux. I know this because:

  1. The file b1 is in the ELF (Extensible and Linkable Format) format, while Mac OS X uses the Mach-O format for binaries;
  2. file recognizes this file is for GNU/Linux 2.6.18 , meaning it’ll work on most modern Linux distributions.

To solve your problem, you must either run this problem within a Linux distribution, recompile the program, or get the Mac OS X version of this program.

So. Why doesn’t b1 work on XYZ OS or CPU?

Just as people speak different languages, different computers understand different instructions. For instance, your Mac uses an Intel processor, while your Android phone uses an ARM processor. Compare these two processors to English and French. They may belong to the same language family, but still, you can’t speak both at the same time. This leads to a conclusion:

Dissimilar computers «talk» in different tongues.

As for why different operating systems (such as Windows, Mac OS X, and Linux) can’t use the same binaries, consider this:

What makes software objectively different to hardware? Not much.

Both provide a system and a «language» that allows for more complex components of the computer to complete tasks for the end user. Both require an agreed language to get work done. Imagine if there were 10 people in a shouting match, each speaking a different language. This is why different OS software need different binaries, even if both operating systems use the same processor.

Источник

cannot execute binary files on MAC terminal

I’ve used makefile to generate file. gcc -c hello.c -o hello and fixed the permission problem through: chmod a+x ./hello However, when I want to execute «hello» file. ./hello the system told me that «cannot execute binary file» Can someone help me? I am looking forward your reply badly.

3 Answers 3

The -c argument to gcc produces an object file which you later on must link in order to produce an executable. You can not execute the object file you produced.

Instead, to compile and link at the same time, suitable when you only have 1 .c file, do

Or if you want to break it down to separate compilation and linking steps, do

Check whether the GCC compiler is installed in your system correctly or not.

Running your program:

As an alternative to compiling and linking at the same time you can use make :

Note: without the .c extension.

The terminal output should be:

Not the answer you’re looking for? Browse other questions tagged c macos shell gcc or ask your own question.

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2020.9.18.37632

Источник

‘cannot execute binary file’ error on a Mac #114

Comments

Copy link Quote reply

andyprata commented Nov 6, 2015

I’m new to polar2grid and I’ve just downloaded the CSPP_IMAPP_POLAR2GRID_V2.0.tar.gz bundle from here: http://cimss.ssec.wisc.edu/cspp/download/index.php

I’ve followed the installation instructions however when I try to run any of the bash scripts I get this error:

I believe I have the polar2grid home path correct:

I’ve also tried the following combinations to make the bash script executable:

But I still get the same ‘cannot execute binary file’ error. I’m on a Mac system (OS X 10.10.5 Yosemite) running the bash shell from Terminal. Any help on this would be much appreciated.

Copy link Quote reply

djhoese commented Nov 6, 2015

Hi Andy,
The tarball available from the CSPP site is for 64-bit RHEL 5+ (or CentOS 5+) linux systems only. You won’t be able to run that specific installation on a Mac. You can run Polar2Grid on a Mac, but we do not provide an all-in-one installation package like we do for our linux users. We have instructions on our documentation website for installing the individual python packages (does not include corrected reflectance software):

To do this on a mac I highly suggest using Anaconda or Macports or Homebrew to install a Python 2.7 environment and then run the commands mentioned in the documentation. Hope this helps.

Copy link Quote reply

andyprata commented Nov 6, 2015

Thanks for such a quick response–I suspected that it was because I’m not on Linux. I’ve tried installing polar2grid from source by running sudo python setup.py install in here:

/polar2grid-master/py/polar2grid and I get the following error:

Do you think this issue is related to my Enthought Canopy installation of python or something else?

Copy link Quote reply

djhoese commented Nov 7, 2015

@andyprata, do you plan on modifying the code? Otherwise, is there a reason you are installing from the source code? Do the installation instructions at the webpage I provided not work for you?

I highly recommend never installing python packages using «sudo». Almost every command used for installing python packages has a —user flag that can be added so you install packages in a

/.local directory. This way you don’t run things as root and you don’t modify the installed python environment. If you don’t need to modify the code I suggest installing things with the command from the webpage (with the added —user):

This should find all of the core packages at our SSEC server. The reason your command failed is that our Polar2Grid packages are not made available through the normal and public PyPI package repository. If you need to modify the code I would suggest you install from source using this command:

Источник

Cannot execute Binary file on Mac OS

Here is a repo that I am trying to clone.

It says, we support UNIX based system. So I tried running «make tag» on OSX terminal.

But it gives this error:

I saw some of the answers previously asked on superuser but weren’t helpful.

1 Answer 1

Even though the Bitbucket page says they support «UNIX», but I think they really mean just Linux. The make script needs to run their included bin/tnt program. Running file bin/tnt shows:

For comparison, a «normal» Mac OS X UNIX command (like man ) returns this:

Conclusion: the bundled tnt program is not Mac-compatible.

Workaround 1: Download/compile a Mac version of tnt ? Given what you’re trying to accomlish, I’m guessing this is the TNT homepage: http://www.coli.uni-saarland.de/

But, they don’t make it easy to get the source code, so I’m not sure how lucky you’ll be trying that path.

Workaround 2: Get or borrow a Linux computer.

Источник

Question: Q: /bin/bash: cannot excute binary file

I was changing paths and I think I screwed up. My terminal shows

«/bin/bash: /bin/bash: cannot execute binary file»

MacBook Pro, Mac OS X (10.6.8)

Posted on Jun 27, 2011 3:45 PM

Helpful answers

/opt . I guess that’s something created by or for macports. Personally I would use /usr/local/bin.

I’m still curious what wrong with your original /bin/bash. If you can put your version of bash most anywhere and it executes ok then I would be wondering what happened to the original /bin/bash. Do the following two terminal commands and post the results:

file /bin/bash

ls -l /bin/bash

Jun 29, 2011 12:59 AM

and use it to extract a fresh copy of bash from your installation DVD

/opt/local is where MacPorts.org puts its stuff, just as Fink.sf.net puts its stuff in /sw. In both cases it means they do not interfere with typical open source installations. You as a user get to choose via your PATH, shell aliases, shell functions, and personal shell scripts which version of a package you use (MacPorts, Fink, Open Source, Mac OS X).

But as has been suggested, you do not really want to replace anything normally installed by Mac OS X, as you never know if it is exactly the same as what was there, and if Mac OS X has some script it needs during normal operation that would break if you replace the Mac OS X version.

And with that in mind, and considering the importances of ‘bash’ it might be very wise to either use Pacifist, or reinstall Mac OS X so that you have a clean ‘bash’ copy.

Источник

Решение проблемы с ошибкой «bash: не удаётся запустить бинарный файл: Ошибка формата выполняемого файла»

В операционной системе Linux при запуске скаченного файла, либо при запуске самостоятельно скомпилированного файла вы можете столкнуться с ошибкой:

Если у вас англоязычная локаль, то ошибка будет примерно такой:

В самой ошибке вместо /путь/до/файла и ./program будет указан путь до файла программы, который вы хотите запустить.

Причинами данной ошибки могут быть:

  • попытка запустить 64-битный файл на 32-битной системе
  • файл скомпилирован для другой архитектуры (например, для ARM, а вы пытаетесь запустить его на ПК)
  • вы пытаетесь выполнить не исполнимый файл, а ссылку
  • файл размещён в совместной (shared) папке

Чтобы получить информацию о файле, который вы пытаетесь запустить, можно использовать утилиту file, после которой укажите путь до файла:

Здесь мы видим, что файл предназначен для 64-битной системы, об этом говорит запись 64-bit, для процессора с архитектурой x86-64.

Этот файл для 32-битных систем, для процессора с архитектурой ARM EABI4.

Если вы не знаете, какой битности ваша система, то выполните команду:

Для 64-битных систем будет выведено x86_64, а для 32-битных – x86.

О разрядности дистрибутивов Linux и о программ

На компьютер с 32-битным процессором вы можете установить только 32-битную операционную систему и в ней запускать только 32-битные программы.

На компьютер с 64-битным процессором вы можете установить как 64-битную ОС, так и 32-битный Linux. В случае, если вы установили 64-битный дистрибутив Linux, то в нём вы можете запускать и 64-битные программы и 32-битные. А если вы установили 32-битный дистрибутив, то в нём возможно запускать только 32-битные программы.

Итак, если у вас 32-битная система, а файл для 64-битной системы или даже для ARM архитектуры, то у вас следующие варианты:

  • скачать файл подходящей для вас битности и архитектуры
  • если вы самостоятельно компилировали файл из исходного кода, то заново скомпилируйте для процессора вашей архитектуры

Запуск ARM файлов в Linux

Часто можно запустить исполнимые образы ARM на amd64 системах если установить пакеты binfmt-support, qemu, и qemu-user-static:

Заключение

Итак, ошибка формата выполняемого файла с невозможностью запустить бинарный файл возникает из-за несоответствия программы операционной системе или архитектуре процессора. Эта проблема не должна возникать, если вы установили программу из исходных репозиториев (кроме случаев неправильной настройки источников репозитория). При возникновении этой проблемы поищите файл, подходящий для вашей архитектуры или скомпилируйте файл из исходных кодов под архитектуру вашей операционной системы.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os calendar google calendar
  • Mac os brew mysql
  • Mac os brew install
  • Mac os bootcamp установка windows
  • Mac os boot log