[llvm-dev] ld.lld fails with "undefined symbol: _fopen" on macOS, while working as expected on Linux

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 7 12:34:27 PDT 2019

Hi Ivan,

On Fri, 7 Jun 2019 at 11:19, Ivan Medoedov via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> LLD 8.0.0 (compatible with GNU linkers)
> ld.lld: error: undefined symbol: _fopen
> >>> referenced by fopen.c
> >>>               test.o:(main)

I suspect you're getting the macOS version of stdio.h, which makes
fopen some kind of alias. You really should use a sysroot when
cross-compiling, though you *might* get away with just
-I/path/to/linux/usr/include. Just what you've copied across might
well be sufficient to use with --sysroot.



More information about the llvm-dev mailing list