Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

how to link math.h

Altera_Forum
Honored Contributor II
1,865 Views

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&#39;: 

: undefined reference to `sin&#39; 

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 !
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
908 Views

I have similar problem,too. 

But my problem is "#include<asm/io.h> ",why? 

Thanks!!
0 Kudos
Altera_Forum
Honored Contributor II
908 Views

I found the method to solve problem from the network. 

need to add the "-lm" in command  

 

nios2-linux-uclibc-gcc test.c -o test -elf2flt -lm
0 Kudos
Altera_Forum
Honored Contributor II
908 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
908 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
908 Views

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&#39;t solve the problem.
0 Kudos
Altera_Forum
Honored Contributor II
908 Views

 

--- 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&#39;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&#39;t meet other problems about path yet.......... 

 

 

jay
0 Kudos
Reply