Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld: library not found for -lgcc_ext.10.5

Tags:

c++

gcc

I'm trying to compile a basic C++ program for school and when I try running it from the Mac Terminal (10.7.6), I get this message:

ld: library not found for -lgcc_ext.10.5
collect2: error: ld returned 1 exit status

I'm definitely in the correct directory and installed XCode Command Line tools. Here is my command prompt:

g++ -o chapter_2 hello_world.cpp

Here is my basic c++ program.

#include <iostream>

using namespace std;

int main(){

  cout << "Hello world" << endl;

}
like image 316
quorum87 Avatar asked Feb 04 '13 20:02

quorum87


2 Answers

As Judd pointed out, the issue is that the linker can't find libgcc_ext.10.5. While I don't have an ideal solution for this, what worked for me was installing gcc-4.8 using homebrew, and using a newer gcc.

brew install gcc48

I believe there is even gcc49 now. Using this I was able to compile without problems (though note that I had to use $ gcc-4.8 ... in the console, as $ gcc ... still points to the older gcc version (unless you explicitly change that).

like image 136
Nate Avatar answered Nov 12 '22 22:11

Nate


I had the same problem, on OS X 10.8, with both current XCode and gcc installed by Homebrew.

When I checked $ which g++ it gave /usr/local/bin/g++.

So I commented this path in .bash_profile:

#PATH="/usr/local/bin:${PATH}"

Now $ which g++ gives /usr/bin/g++ and its version indicates that it is from XCode and there is no ld: library not found for -lgcc_ext.10.5 error.

like image 31
Piotr Migdal Avatar answered Nov 12 '22 22:11

Piotr Migdal