Chris Wolf
Chris Wolf

Reputation: 1768

Where is the standard 'C' shared library on MacOS-11 or higher?

Hi I'm trying to create a shared library on MacOS-11.x.x but I get the following errors related to standard C library symbols missing:

(venv) ELSPHIM-223046:pyembed wolf2$ ./linkit
ld: warning: object file (pyembed.o) was built for newer macOS version (11.0) than being linked (10.4)
ld: warning: dylib (/Users/Shared/venv/lib/libpython3.11.dylib) was built for newer macOS version (11.7) than being linked (10.4)
Undefined symbols for architecture x86_64:
  "___stderrp", referenced from:
      _main in pyembed.o
  "_atoi", referenced from:
      _main in pyembed.o
  "_fprintf", referenced from:
      _main in pyembed.o
  "_printf", referenced from:
      _main in pyembed.o
ld: symbol(s) not found for architecture x86_64
fatal error: /Library/Developer/CommandLineTools/usr/bin/libtool: internal link edit command failed

I tried:

libtool -dynamic pyembed.o  /Users/Shared/venv/lib/libpython3.11.dylib -o dddd.dylib -current_version 1.0 -compatibility_version 1.0

As you can see, I'm trying to build another shared library to invoke an embedded Python function, which works when linked as an application. I think that detail is unimportant since the only undefined symbols are from libc.

So now I try to find libc by: otool -L /bin/ls - that reports:

$ otool -L /bin/ls
/bin/ls:
    /usr/lib/libutil.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.120.1)

But then I do:

$ ls -l /usr/lib/libSystem*
ls: /usr/lib/libSystem*: No such file or directory

So how does /bin/ls even work? Where is libc (either .a or .dylib) on MacOS?

I already included that information in my post.

Upvotes: 1

Views: 260

Answers (0)

Related Questions