두 개의 간단한 소스 파일이 있습니다 : main.c
void main(){
print_hello();
}
hello.c
#include<stdio.h>
void print_hello(){
printf("Hellow world \n");
}
bash 명령으로 컴파일 한 후 :
gcc -c hello.c
gcc -c main.c
괜찮아. 입력 할 때 gcc -o hello.o main.o
오류가 발생하는 이유 :
main.o
main.o: In function `main':
main.c:(.text+0x7): undefined reference to `print_hello'
collect2: error: ld returned 1 exit status
하지만 gcc -o hello hello.o main.o
잘 작동합니까?
gcc -o hello.o main.o
의미 : " hello.o
후속 파일 ( main.o
) 을 연결하여 실행 파일 출력 ".
gcc -o hello hello.o main.o
의미 : " hello
후속 파일 ( hello.o
및 main.o
) 을 연결하여 실행 파일 출력 ".
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다