cannot execute binary file: Exec format error 해결 방법좀 공유해주세요..

jytg669의 이미지

간단한 C언어 코드 빌드를 하려는데 오류가 나서 질문 드립니다.

코드: hello.c

#include <stdio.h>
 
int main(){
 
    printf("Hello World"");
 
    return 0;
}

gcc : -> gcc -c hello.c
생성된 object 실행 -> ./hello.o
+에러 문구+
-bash: ./hello.o: cannot execute binary file: Exec format error

에러문제 예시 확인
1. 비트가 안맞아서 그런다.
현재 ubuntu ver: x86_64
object_file : hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

다음에 제가 무슨 확인을 해봐야 할까요?.. 아무리 찾아도 잘 모르겠어서요..ㅠㅠ

semjase의 이미지

프로그래밍 Q/A에 질문을 올리셔야할듯 합니다.

gcc -o hello hello.c
./hello
이렇게 하셔야

object파일은 실행화일이 아닙니다.

.

익명 사용자의 이미지

*.C CODE == COMPILE ===> *.O (OBJECT FILE) ==LINK&LOAD ==> EXECUTABLE FILE !!

//reference
compile's detail phases

.c ==pre processor ==> .i ===compile==> .s ====assemler===> .o