Forum Discussion
Altera_Forum
Honored Contributor
20 years agohow to link math.h
hi all
When I run a program with trigonometric function like sin, cos,tan etc.. I get errors: <div class='quotetop'>QUOTE </div> --- Quote Start --- [jay@localhost test]$ nios2-linux-uclibc-gcc test.c -o test -elf2flt test.elf2flt(.text+0x6c): In function `main': : undefined reference to `sin' collect2: ld returned 1 exit status[/b] --- Quote End ---#include<math.h># include<tgmath.h>
main()
{
double angle;
angle = asin (60);
printf("angle = %f\n",angle);
} What should I do? thx in advance !6 Replies
- Altera_Forum
Honored Contributor
I have similar problem,too.
But my problem is "#include<asm/io.h> ",why? Thanks!! - Altera_Forum
Honored Contributor
I found the method to solve problem from the network.
need to add the "-lm" in commandnios2-linux-uclibc-gcc test.c -o test -elf2flt -lm - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by wolaiye3@May 19 2006, 01:33 PM i have similar problem,too.but my problem is "#include<asm/io.h> ",why?
thanks!!
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15467)
--- quote end ---
--- Quote End --- hi, perhaps u have to specify the whole path of io.h like the following for example :# include <C:\altera\kits\nios2\bin\eclipse\workspace\kernel\build\include\nios2_system.h> http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif
- Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by sdhnain+may 20 2006, 01:57 am--><div class='quotetop'>quote (sdhnain @ may 20 2006, 01:57 am)</div>--- quote start ---
<!--quotebegin-wolaiye3@May 19 2006, 01:33 PM i have similar problem,too.
but my problem is "#include<asm/io.h> ",why?
thanks!!
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15467)
--- quote end ---
--- Quote End --- hi, perhaps u have to specify the whole path of io.h like the following for example :# include <C:\altera\kits\nios2\bin\eclipse\workspace\kernel\build\include\nios2_system.h> http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15470)</div> [/b] --- Quote End --- Thanks!! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/laugh.gif
- Altera_Forum
Honored Contributor
Hi wolaiye and jay.
I meet the same problem? did you solve the problem? and how to ? I try to and full path, but it don't solve the problem. - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by zzh@May 24 2006, 08:36 AM hi wolaiye and jay.i meet the same problem?
did you solve the problem? and how to ?
i try to and full path, but it don't solve the problem.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15548)
--- quote end ---
--- Quote End --- hi zzh i can link math.h lib and use math function in my app program,now. when i use pio ports that copy "nios2system.h" to my app folder with using include "nios2system.h". so i don't meet other problems about path yet.......... jay