4

Backstory: I started using my terminal for a lot of my school projects. I recently got familiar with it and wanted to "upgrade" by installing iTerm2 and homebrew; but before I installed the two, I was able to compile my C++ homework files "g++ filename.cpp" and run "./a.out" no problem. After installing iTerm2 and homebrew followed by xcode commandline tools I started running into this problem every time I try to compile my c++ files:

"ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)"

I created a simple "Hello World!" c++ and that won't even compile. I've tried everything even some posts on here. Hopefully someone has a different solution. Thank you in advance!

The code is super simple:

#include<iostream>

using namespace std;

int main() {
    cout << "Hello World!" << endl;
    return 0;
}

How I tried compiling it: "g++ main.cpp" Which back then I get an a.out file but this time I get that error message shown in the picture.

I added more photos showing my g++ version and also the attempt of compiling it: "g++ -Wall -Wextra -g main.cpp -o prog.bin" I'm also running macOS Catalina 10.15.6 Thank you in advance. I'm reading through the documentations provided rn.

g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

enter image description here

UPDATE: I uninstalled and reinstalled Xcode CommandLineTools and homebrew; however, this time I did not update the CommandLineTools to beta 5 like I did before.

enter image description here

Now I'm able to compile and run my school assignments. Not an ideal solution but I'm back to working on my school assignments peacefully. Thank you all for the help!! I guess installing the beta CommandLineTools is not such a great idea.

enter image description here

saxbophone
  • 779
  • 1
  • 6
  • 22
Leo
  • 51
  • 4
  • 1
    I don't get errors when I compile that on my mac. You probably need to figure out exactly which toolchain is being used. – Carlos Aug 21 '20 at 08:22
  • And the C++ compiler is [Clang](http://clang.llvm.org/) whose documentation is [online](http://clang.llvm.org/docs/UsersManual.html) and quite well written. I strongly suspect a system misconfiguration or some hardware problem, and suggest to at least reinstall the C++ compiler and toolchain – Basile Starynkevitch Aug 21 '20 at 08:48
  • 1
    Did you install gcc via brew too, that may cause conflicts ? (check by `brew search gcc` and see if an entry has green tick next to it). Also, why do you need to use gcc ? try clang with `-std=gnu++14`. –  Aug 21 '20 at 08:57
  • 1
    @anki I didn't install gcc via brew, but I did now and it works perfectly. I just don't wanna update the CommandLineTools like I added in my post; I fear it might break again lol. Thank you though for mentioning it, it gave me the idea to install gcc-10 and link g++-10 on my /usr/local/bin to just g++ which works great. – Leo Aug 22 '20 at 08:36
  • Do you have any specific reason to try and use a *beta* version of development tools? Sometimes it’s problematic and this may be one of those unfortunate times. If you don’t have the time to troubleshoot such issues, I’d suggest staying away from betas of development tools. – Kuba hasn't forgotten Monica Jan 02 '21 at 09:16

0 Answers0