Search code examples
gccmakefile

gcc error: wrong ELF class: ELFCLASS64


I was trying to compile a program using an external compiled object coreset.o. I wrote the public01.c test file and my functions are in computation.c, both of which compiles. However its failing on linking it together. What might be the problem?

gcc -o public01.x public01.o computation.o coreset.o
ld: fatal: file coreset.o: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to public01.x
collect2: ld returned 1 exit status

Solution

  • I think that coreset.o was compiled for 64-bit, and you are linking it with a 32-bit computation.o.

    You can try to recompile computation.c with the '-m64' flag of gcc(1)