Tips/에러모음

Xcode, CLion - C++ <bits/stdc++.h> header not found

beeem 2021. 10. 29. 00:46

m1 macOS 몬터레이 업그레이드 후 C++ 프로젝트에서 bits/stdc++.h 헤더를 찾을 수 없다는 에러 해결법

 

기존 include 폴더는

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/bits

위 경로에 있었고

 

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

업데이트 이후 위 경로로 새로 바뀌었다.

 

터미널에서

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

명령 수행 후 

bits 폴더를 새로 만들어서(sudo mkdir bits) 안에 stdc++.h 파일 생성해주면 해결된다.

 

추가로 Xcode (13.1 ver)에서 계속 헤더를 찾을 수 없다고 하면

프로젝트명을 더블클릭하면 아래와 같은 창이 탭이 뜨고 Build Settings - Apple Clang - Language - C++로 가서

C++ Standard Library를 libc++(LLVM)으로 바꿔준다.