简体   繁体   中英

arm-gcc unresolved reference 'sinf'

I'm getting this error when trying to compile:

error: undefined reference to `sinf'

I have included math.h, and verified that it is defined in there:

#include <math.h>

However, I get an error while trying to link to the math library:

arm-none-eabi-ld -L/usr/lib -lm --gc-sections -T ../standalone.ld -o "main.elf"  ./main.o ./startup_gcc.o  
error: cannot find -lm

However, the library is obviously there:

Kens-MacBook-Pro:lib Ken$ pwd
/usr/lib
Kens-MacBook-Pro:lib Ken$ ls | grep libm
libm.dylib
libmecab.1.0.0.dylib
libmecab.dylib
libmecabra.dylib
libmenu.5.4.dylib
libmenu.dylib
libmx.A.dylib
libmx.dylib
Kens-MacBook-Pro:lib Ken$ 

What am I doing wrong? I'm using Eclipse.

Judging by your arm-none-eabi-ld command, I'm assuming you're cross compiling. You need to install some sort of math library into the toolchain for whatever your platform is.

The ls output you posted contains a list of libraries available for your host, not your target. On my machine, the libraries for my ARM cross-compiler resides in /opt/local/arm-none-eabi/lib/ for example.

danieltang ~$ ls /opt/local/arm-none-eabi/lib/
crt0.o      ldscripts  libm.a     libssp_nonshared.a   libstdc++.a-gdb.py  libsupc++.la
elf2flt.ld  libc.a     libssp.a   libssp_nonshared.la  libstdc++.la    thumb
fpu         libg.a     libssp.la  libstdc++.a          libsupc++.a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM