在 xilinx SDK 使用 math.h


在使用到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中設置




 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM