I installed gcc by brew on Mac OS mojave, but both of gcc and g++ are not working.
I tried compile below simple code by g++ but I got error messages.
This program can be compiled correctly by default clang, so I am wondering there is any library link error. But I am not sure.
I got same error in the case of gcc.
#include <iostream>
using namespace std;
int main(){
int i;
cin >> i;
cout << i * 2 + 1 << endl;
}
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd Undefined symbols for architecture x86_64: "___cxa_atexit", referenced from: __static_initialization_and_destruction_0(int, int) in ccEBCemd.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status
g++ -v says
Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_1/libexec/gcc/x86_64-apple-darwin18/9.2.0/lto-wrapper Target: x86_64-apple-darwin18 Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.2.0_1 --libdir=/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_1' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk Thread model: posix gcc version 9.2.0 (Homebrew GCC 9.2.0_1) `
Thank you.