기타, 이외 에러 해결 사항

[vscode] C언어 vscode에서 undefined reference to 에러 날 때

til_t 2021. 1. 22. 19:53
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x3f): undefined reference to `LInsert'    
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x50): undefined reference to `LInsert'    
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x61): undefined reference to `LInsert'    
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x72): undefined reference to `LInsert'    
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x7e): undefined reference to `LCount'     
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x9c): undefined reference to `LFirst'
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0xd4): undefined reference to `LNext'      
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0xf4): undefined reference to `LFirst'     
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x10c): undefined reference to `LRemove'   
C:\Users\AUTOMA~1\AppData\Local\Temp\ccjSCp6n.o:ListMain.c:(.text+0x122): undefined reference to `LRemove'  

 

.h 헤더파일을 불러오려고 할 때, 위와 같이 undefined reference to 에러가 난다면

 

터미널에 

$ gcc -o (생성할 이름) (main 함수 c파일) (연결된 c파일)

위와 같은 형식으로 다시 컴파일하면 생성한 이름.exe이 생성된다.

터미널에 생선한이름을 명령어로 실행하면 잘 실행된다.

$ 생성한 이름

 

만일 한글이 깨져서 나온다면, vscode 오른쪽 하단의 인코딩 선택에서 EUC-KR로 인코딩하며 다시 열기를 한다.