首页 > 技术文章 > 在 xilinx SDK 使用 math.h

ldjrl2013 2015-10-15 10:52 原文

在使用到cos sin tan等算法的时候添加了math库

#include <math.h>
但是却报错了

'Invoking: ARM gcc linker'
arm-xilinx-eabi-gcc -Wl,-T -Wl,../src/lscript.ld -L../../gpio_bsp/ps7_cortexa9_0/lib -o "gpio.elf" ./src/main.o ./src/platform.o ./src/video_frame_buffer.o ./src/video_resolution.o ./src/zed_hdmi_conf.o ./src/zed_hdmi_display.o ./src/zed_iic_axi.o -Wl,--start-group,-lxil,-lgcc,-lc,--end-group
./src/main.o: In function `main':
J:\work\zedboard\gpio\gpio.sdk\gpio\Debug/../src/main.c:31: undefined reference to `cos'
collect2.exe: error: ld returned 1 exit status


编译时像这样就行
gcc -o abc abc.c -lm
 
编译程序时得到undefined reference to 'xxxx'这样的错误提示 
那你一定是缺少某个库,用 -l参数将库加入。Linux的库命名是一致的,一般为libxxx.so,或libxxx.a,libxxx.la,那么你要链接某个库就用-lxxx,去掉头lib及"."后面的so,la,a等即可。 
同时,常见的库链接方法为: 
数学库 -lm
 
SDK中设置




 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

推荐阅读