상황
헤더파일(MyString.h), 구현 파일(MyString.cpp), 그리고 이를 이용해서 프로그램을 실행하는 파일(Ex0301_StringAbstractDataType)이 나눠져있는 구조로 실습을 하던 중
clang: error: linker command failed with exit code 1 (use -v to see invocation)
에러가 발생했다.
원인
구글링으로 찾은 에러의 원인은 두 가지가 있다.
1. vscode가 mac에서 자동으로 파일을 링크해주지 않은 것 (https://stackoverflow.com/questions/66502205/mac-os-vs-code-insiders-code-runner-undefined-symbols-for-architecture-arm6)
2. 인텔 맥에서 빌드해야 할 파일을 m1 기반 맥에서 실행해서 오류가 난 것 (https://velog.io/@chaemin/Mac-m1-clang-error-linker-command-failed-with-exit-code-1-use-v-to-see-invocation-%EC%97%90%EB%9F%AC)
해결
둘 중 정확하게 어떤 원인때문인지는 모르겠지만, 위 stackoverflow에서 제시해준 해결 방법인 링크해야할 파일을 컴파일할 때 같이 작성해줘서 해결할 수 있었다.
'Language > C, C++' 카테고리의 다른 글
char[] 과 char*의 차이점 (C++) (0) | 2024.05.27 |
---|