Page 1 of 1

Static Library

Posted: Thu Aug 13, 2026 1:04 am
by Typan
Hello,

I am working on a custom operating system and I want create static libraries. I am working on a MacBook M4 (silicon).

I am using the compiler x86_64-elf-gcc and linker x86_64-elf-ld. The problem is when I create a static library with command:

ar -r libc.a *.o I get a library. But if I am using command ranlib I get response:

warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: libc.a the table of contents is empty (no object file members in the library define global symbols)

And the library is not working with the linker.

Does anybody know what is wrong?

Kind regards,
Robert

Re: Static Library

Posted: Thu Aug 13, 2026 1:49 am
by klange
You need to use the ar and ranlib that came with your linker, which should exist with the same prefix, eg. x86_64-elf-ar and x86_64-elf-ranlib. The unprefixed ones you are using on macOS are part of a mach-o toolchain and do not understand your ELF object files.

Re: Static Library

Posted: Thu Aug 13, 2026 2:43 am
by Typan
Hi klange,

Thank you so much for this answer and it is working :-)

Kind regards,
Robert