7

My situation

  • Mac OS Monterey 12.1 (M1, 2020)
  • Visual Studio Code v1.64.2

Everytime I try to compile cpp file, the warning below is shown in terminal.

ld: warning: dylib (/usr/local/Cellar/gcc/11.2.0/lib/gcc/11/libstdc++.dylib) was built for newer macOS version (11.3) than being linked (11.1)

I have no idea how to fix this.
I read this stackoverflow, and tried the below command, but did not change the situation.

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
ktakehi
  • 249
  • 1
  • 3
  • 13
  • Have you tried checking which version of gcc you've installed? If after updating with `xcode-select --install` you try to uninstall and reinstall gcc. Do you still receive the same error? What's the output of: `brew info gcc` Do you have any updates available? – pablora Jun 16 '22 at 05:43

1 Answers1

6

export MACOSX_DEPLOYMENT_TARGET=11.3 can eliminate the warning.

Nuo Y
  • 76
  • 1
  • 3
  • It helps me with "export MACOSX_DEPLOYMENT_TARGET=12.0". My warning msg is "ld: warning: dylib (/usr/local/lib/libX11.dylib) was built for newer macOS version (12.0) than being linked (11.3)". – Golden Thumb Mar 01 '23 at 16:43