MacOS Sonoma로 업데이트 이후 VSC c++ 에러

hunnypooh·2024년 6월 16일
post-thumbnail
  1. 업데이트 미루고 미루다가 이제 하는데, 코테 풀려고 VSC에서 C++ 하다가 에러남.

에러 1: command not found: g++-12

which g++

g++: aliased to g++-12 라고 나옴.

g++ version

zsh: command not found: g++-12 라고 나옴

해결 1: g++12 설치

brew info gcc

gcc: stable 14.1.0 라고 나와서 12로 설치해야 될거같아서 진행.

sudo xcode-select -s /Library/Developer/CommandLineTools

이러고 g++ --version 해서 잘 나오면 됨.

문제 2: <bits/stdc++.h> include 에러

코드에 빨간줄로 #incldue <bits/stdc++.h> 부분에 include 오류가 검색되어 includePath를 업데이트 하라고 해서 함.

해결 2: c_cpp_properties.json 수정 및 파일 추가

이걸로 c_cpp_properties.json 파일에서 추가함

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/Library/Developer/CommandLineTools/usr/include/bits"
            ],

includePath에 bits 폴더 저장함.
저 경로는 clanng --version 에서 나오는 경로 참고하면 됨. (저번 글 참고)

근데 하니까 위치에 파일 없다고 경고 떠서 가보니까 진짜 파일 없어짐...

/Library/Developer/CommandLineTools/usr/include 위치 가니까 아예 bits 폴더가 없어서 bits/stc++.h 파일 생성해줌.

profile
간단한것들 정리

0개의 댓글