ld: library lgcrt not found error!

Hello,


I am having an identical error to this thread: ld: library not found for -lgcrt1.o error - Apple Community


Unfortunately, the solution in this thread does not actually work. I have installed lgsl via brew. I have updated my zshrc as below:


```

alias gcc="gcc-14"

alias g++="g++-14"

export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix)/lib:$(brew --prefix)/opt/libiconv/lib


export PATH="/usr/local/opt/libiconv/bin:$PATH"


export LDFLAGS="-L/usr/local/opt/libiconv/lib"

export CPPFLAGS="-I/usr/local/opt/libiconv/include"


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


And still nothing works when trying to compile a c++ program with pg flags just like the OP.


Example:


```

username@user cowtour % g++ -pg cowtour.cpp

ld: library not found for -lgcrt1.o

collect2: error: ld returned 1 exit status

```


How did you all go about fixing this? I saw there 31+ "Me too" flags for the error in the linked post.

MacBook Pro 15″

Posted on May 17, 2024 7:26 PM

Reply

There are no replies.

ld: library lgcrt not found error!

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