Command line c code running error - dyld: Library not loaded: usr/lib/libSystem.B.dylib

Hello there,

I have an M1 macbook with updated big sur 11.1


The basic hello.c compiled by clang runs fine but when I did some other multi c files it failed with "Library not loaded: usr/lib/libSystem.B.dylib" running error message.

Most time I got this error, but somehow it worked once.
When I did Xcode with swift sample compiling it works great.

The other iMac with the newest big sur works fine when I did the same testing!

I know big sur removed lib files, but this is so weird along with iMac testing.

Thanks for your time.


Answered by Robin-Chang in 653084022

For those who might have the same issue:


1 It's a problem of Big sur or xcode, I refresh my disk with brand new big sur 11.1 and no problem at all.
2 I am disappointed with Apple support because they transferred my case and no one was able to handle it.
3 Apple guys in here may think my question is stupiid they just didn't want to answer.
The messages followed by "Reason: Image not found"
Additional info:

Both iMac and M1 MacBook otool info are:

***:
/lib/usr/libSystem.B.dylib

locate libSystem.B.dylib
/application/Xcode/xxxxxxxxxxxxxxxxxxxxxxxxx/libSsytem.B.dylib
And I tried  -lSystem -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib posted on the other questions and no luck.

On the iMac clang without any options like clang -o *** *.c
In case someone can help:

1 All the basic c code can be compiled and ran on iMac(Big sur 11.1) without additional lib (clang -o mycode mycode1.c mycode2.c)
2 M1 macbook(Big sur 11.1) can run basic helloworld.c binary code but failed when I test binary with multi c code files, like clang -o mycode mycode1.c mycode2.c
3 Both iMac and M1 macbook air don't have any compiling issues
4 Error message "Library not loaded: usr/lib/libSystem.B.dylib" "Reason: Image not found"
5 otool -L mycode on both iMac and M1 macbook Air: "/lib/usr/libSystem.B.dylib"
6 locate libSystem.B.dylib on both iMac and M1 macbook Air: /application/xcode.app/xxxxxxx/appletvos(watchos/iphoneos)/xxxxxxxxxxxxxxxxx/libSystem.B.dylib
7 M1 installed xcode twice, and clang - 1200.0.32.28, ld64-609.8
Accepted Answer

For those who might have the same issue:


1 It's a problem of Big sur or xcode, I refresh my disk with brand new big sur 11.1 and no problem at all.
2 I am disappointed with Apple support because they transferred my case and no one was able to handle it.
3 Apple guys in here may think my question is stupiid they just didn't want to answer.
Command line c code running error - dyld: Library not loaded: usr/lib/libSystem.B.dylib
 
 
Q