ld: library not found for -lgcrt1.o error

I have a macbook pro running mojave.
 
I trying to profile a program which works perfectly. When I compile 
with -pg using clang as follows 


clang  test_program.c  -o test_program_pg   -pg


I get the following error


clang: error: the clang compiler does not support -pg option on 
versions of OS X 10.9 and later

So i installed gcc with brew and tried to compile with -pg. This time I get

ld: library not found for -lgcrt1.o
collect2: error: ld returned 1 exit status

The gcc I used was /usr/local/Cellar/gcc/10.2.0/bin/gcc-10

How can this be fixed?



MacBook Pro 15″, macOS 10.13

Posted on Nov 11, 2020 11:22 PM

Reply

Similar questions

1 reply

Nov 12, 2020 6:41 AM in response to red_wood

I just wanted to say that I had the exact problem on OSX. Rather than setting an environment variable, I used an additional compiler flag -L/opt/local/lib, which then lets one use -lgsl. I reference this answer.


Also...


I got the same issue and here is how I fixed it:

export LIBRARY_PATH=/usr/local/Cellar/gsl/1.16/lib/

I had previously installed gsl using:

brew install gsl


https://stackoverflow.com/questions/16682156/ld-library-not-found-for-lgsl


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.

ld: library not found for -lgcrt1.o error

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