Я получаю следующую ошибку при выполнении моего двоичного файла test1:
$ ./test1
bash: ./test1: cannot execute binary file: Exec format error
Я проверил, что у меня есть 'x' право на этом двоичном файле:
$ ls -la test1
-rwxrwxrwx 1 *** *** 5864 Apr 9 17:04 test1
Я также проверил, что и мой файл и моя человечность, на которой работают x86-64, предназначаются:
$ file test1
test1: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
$ uname -a
Linux ubuntu 5.3.0-46-generic #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Наконец, моя gcc версия:
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Вы могли помочь?
Команда, которую Вы использовали
gcc -g -Wall -c test1.c -o test1
создает двоичный объектный файл, не исполняемый файл. От man gcc
:
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.
Для создания исполняемой программы необходимо позволить gcc
продолжаться к фазе ссылки путем удаления -c
опция:
gcc -g -Wall test1.c -o test1