Can't run C++ code after updating the Command line tools(maybe?)

blackole@Divyanss-MacBook-Air ~ % g++ test.cpp 
ld: warning: ignoring duplicate libraries: '-lgcc'
0  0x102fd7648  __assert_rtn + 72
1  0x102f0bfac  ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1204
2  0x102f21924  ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15164
3  0x102f2ee30  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 420
4  0x18f1b4440  _dispatch_client_callout2 + 20
5  0x18f1c9544  _dispatch_apply_invoke_and_wait + 224
6  0x18f1c884c  _dispatch_apply_with_attr_f + 1180
7  0x18f1c8a38  dispatch_apply + 96
8  0x102fa93b8  ld::AtomFileConsolidator::parseFiles(bool) + 292
9  0x102f4a170  main + 9048
ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.
collect2: error: ld returned 1 exit status

I don't know what's happening, can't find anything at Google.

Please help, its really important for my work to compile C++ using gcc.

MacBook Air 13″, macOS 13.5

Posted on Sep 19, 2023 10:30 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 19, 2023 10:06 PM

divyans wrote:

What do you mean by 'always homebrew'. Do i have to do something with it to resolve the issue. If yes, then what do i have to do?


etresoft is not fond of homebrew.


Yes, homebrew installs can sometimes go sideways.


If you really need gcc here (and not the clang-provided gcc shim, or clang++ itself), remove and then reload gcc using homebrew, and follow the setup procedure for establishing gcc in your path. But if you don’t specifically need gcc, use clang.

Similar questions

25 replies

Sep 26, 2023 1:22 PM in response to etresoft

etresoft wrote:


osalbahr wrote:

FWIW, if you want to play the numbers game, in case you weren't aware GitHub enumerates both issues and PR's together. In other words, the homebrew-core repo actually has less than 6000 issues.
I don't know if 1.9 bugs per day is quite the win you think it is.

In any event, the number of Homebrew bugs doesn't bother me. It is all the posts here in the developer forum from people who are totally lost that bother me. Day in, day out. zsh doesn't work. ls doesn't work. Apache doesn't work. Paths are broken. We can't help because we have no idea how Homebrew has utterly scrambled the system. And even if we did know, we can't explain how to fix it for people who don't know how any of it works. That's why they are using Homebrew in the first place.


Ok, fair enough, such posts are indeed annoying. It is a fair expectation to comment-out Homebrew’s eval command before making a post. However I think the situation of a breaking upgrade to the linker is different and not exactly specific to Homebrew in that regard, so an Apple discussion post discussing the issue saves time for lots of macOS users, not just Homebrew users.


And I’m curious, seeing how critical you are of Homebrew, how do you propose macOS users should install various command line tools if not using Homebrew?

Sep 27, 2023 2:14 AM in response to etresoft

> The linker isn't broken.


Breaking upgrade != broken. It simply means not backwards compatible.


> Same way it has always been done?


The way “it’s always been done” is through a package manager, such as apt, dnf, pacman, etc. Manually installing from source is very annoying and tedious, but it is fine if you do it only once. The problem is, more often than not, I’d also need to install some of the dependencies from source too, so I resort to build tools like spack.


Depending on your use case, sure, *.dmg files might be sufficient, but that is far from the case for many macOS users. Just look at the numbers. And it is even more if you count installed dependencies, which is the main job of a package manager.


> Failing that, maybe Homebrew could develop a packaging system to easily install 3rd party command line tools? How come they don't do that? Can you tell me why Homebrew installs tools that are already part of the operating system and corrupts command line environments? Why not just install software? Why not test said software? Why not support their software?


Homebrew, in fact, does all of this! To answer your first and main question, one example from the top of my head speedtest.net’s CLI giving instructions to install it, a 3rd party, via Homebrew. There’s also HashiCorp (terraform) maintaining their own Homebrew packages. It is very easy to use 3rd party “taps” and can be done in one command.


I can answer the remaining questions, if you’re interested. Most are easy to find in Homebrew’s website and glancing through the documentation. There seems to be a few misunderstandings, and it seems that Homebrew does not fit your use case so it’s understandable that you don’t know much about its internals.

Sep 27, 2023 6:09 AM in response to osalbahr

osalbahr wrote:

> The linker isn't broken.

Breaking upgrade != broken. It simply means not backwards compatible.

Saying "backwards compatible" implies that this is an Xcode problem. It is not. This is 100% a Homebrew problem. Everyone knew that Apple was going to release a new version of Xcode. Homebrew didn't bother to test their software. Homebrew didn't bother to inform their users. Homebrew didn't bother to support their software. They just sat on their bums and assumed that someone else would fix their problems for them - just like they always do.

The way “it’s always been done” is through a package manager, such as apt, dnf, pacman, etc.

Nonsense. Those package managers are strictly a Linux thing. Even on Linux, they are a royal pain. You can never configure two systems the same way and they regularly fail. 

Manually installing from source is very annoying and tedious

Is that another way of saying "correct"?

it is fine if you do it only once.

Or if you need to do it repeatedly, perhaps in a script, and ensure that each installation is identical. 

The problem is, more often than not, I’d also need to install some of the dependencies from source too, so I resort to build tools like spack.

I'm not here to argue about package managers. Homebrew isn't a package manager, it's junk. 

Depending on your use case, sure, *.dmg files might be sufficient

DMG files? What is this, 1998?

Just look at the numbers. And it is even more if you count installed dependencies, which is the main job of a package manager.

This is not a quantitative issue. It is a qualitative issue. The quality of Homebrew is junk. That's the issue.

Homebrew, in fact, does all of this!

Then why are we arguing in a non-Homebrew forum about how Homebrew has neglected to do any of that? This is the Apple Support community, not the Homebrew support community.

I can answer the remaining questions, if you’re interested. Most are easy to find in Homebrew’s website and glancing through the documentation. There seems to be a few misunderstandings, and it seems that Homebrew does not fit your use case so it’s understandable that you don’t know much about its internals.

I am not interested. My questions were obviously rhetorical and satirical. Homebrew is junk. I'm not about to read up on Homebrew so that I can do their tech support for them. That's their job, not mine. My job is to help my fellow Apple users. One way I can do that is to tell them when they've installed some junk software and help them uninstall it. Homebrew is one of the few apps that is of such poor quality that the only way its target customer base can uninstall it is to erase their hard drive and reinstall the operating system. There's no way that I can explain to someone who needed Homebrew in the first place how to fix it. All I can do is tell them how to reset their system and to avoid this kind of junkware in the future.


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't run C++ code after updating the Command line tools(maybe?)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.