Macbook M1, g++ with linked gsl library, suddenly not working

Hello there, I have a macbook M1 with big sur, I have been using it to compile and run c++ programs for a while with g++ without any problem. Suddenly now when I run an executable I get the error message

dyld: Library not loaded: /usr/lib/libc++.1.dylib
Referenced from: /Users/ga/WorkDirs/./sper300GH  Reason: image not found zsh: abort   ./sper300GH

the funny thing is that randomly the executable sometimes runs. If I run it from shell, after a random number of attempts, instead of abort message, the executable just runs.

I find this very odd, also since this same executable was working fine before.

This problem arises when I am linking the gsl library, but as I said used to work fine before but now gives me an error/abort message (but weirdly sometimes it runs)

I decided to run the pending update to bigsur 11.4 hoping it would fix the issue but it didn't any advice?

Macbook M1, g++ with linked gsl library, suddenly not working
 
 
Q