0

I'm under Windows Linux Subsystem which works well on other computer.

I have a 64-bits file: ./ensembles.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

uname -m: x86_64

I tried with the gcc compiler and the clang one, both loose.

Even this C code doesn't work:

#include <stdio.h>
#include <stdlib.h>

#include "sac.h"
#include "type_ensemble.h"
#include "operations_ens.h"
int main(int argc, char ** argv) {
}

The error: -bash: ./ensembles.o: cannot execute binary file: Exec format error

My Makefile:

ensembles.o : ensembles.c sac.h type_ensemble.h operations_ens.h
    gcc -c ensembles.c
operation_ens.o : operations_ens.c operations_ens.h
    gcc -c operations_ens.c
sac.o : sac.c sac.h
    gcc -c sac.c
main: ensembles.o operation_ens.o sac.o
    gcc -o main ensembles.o operation_ens.o sac.o
Izio
  • 378
  • 6
  • 15

1 Answers1

1

A file of type ELF 64-bit LSB relocatable is a file of ELF type ET_REL, which is not directly executable. It's commonly called an object file or .o file, and it is an input file for the link editor.

You need to link it (either with the gcc or the ld command) to produce an executable. If you are invoking gcc, you must not pass options like -r or -c, or otherwise GCC will not produce an executable.

In the makefile you quote, only the first target will be executed by make because it is the default target. Try moving the rule for main to the beginning of the file, or add a rule

all: main

at the beginning. You can also invoke make main to request building the main file explicitly.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92