[llvm-dev] ld.lld fails with "undefined symbol: _fopen" on macOS, while working as expected on Linux
Ivan Medoedov via llvm-dev
llvm-dev at lists.llvm.org
Fri Jun 7 11:19:13 PDT 2019
Hi,
I'm trying to cross-compile my app.
#include <stdio.h>
int main() {
puts("test");
fopen("test", "r"); // removing fopen() call removes the error
return 0;
}
clang -c -target x86_64-linux-gnu test.c
ld.lld -v -o test -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o test.o
/usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/crtn.o
This works fine on Linux, but when I run the same command on macOS, I get
LLD 8.0.0 (compatible with GNU linkers)
ld.lld: error: undefined symbol: _fopen
>>> referenced by fopen.c
>>> test.o:(main)
I haven't set up --sysroot yet, I just copied all these files from the
Linux machine for now.
This only happens with fopen(). Using puts() or printf() is fine.
LLVM version is 8.0.0.
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190607/595e9293/attachment.html>
More information about the llvm-dev
mailing list