Jump to content
43oh

Recommended Posts

Hello, i am having problems with math library using energia. I always keep getting thi s error. I dont know whats wrong.

 

Error  : http://pastie.org/8127090

 

Here you can read the source : http://pastie.org/8127093#871-872

 

I highlighted the lines which are makeing troubles. Its lines 871 and 872, by commenting them you can avoid getting this error.

float accel_angle_y = atan(-1*accel_x/sqrt(pow(accel_y,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
float accel_angle_x = atan(accel_y/sqrt(pow(accel_x,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
 
Link to post
Share on other sites

I do not have the arm toolchain and is not familiar w/ Energia.

 

If there is not readily answer to your problem, you can try to solve it by using a wonderful gcc tool, namely 'nm', which shows you all the symbols in your libs and objs.

 

You can go to where your library resides and find out which library contains the __errno variable, then make sure in your makefile you also link to it. You can do "nm libxxxx.a" to dump the object list of each library and locate the object that you need to link to.

 

Using msp430gcc as an example to locate "errno", you can see libc.a "provides" the errno variable and if your linker complains that it's not there, you need to add "-lc" to link-in libc.a

 

 

chrisc@SW20101105A:/cygdrive/c/mspgcc-20120406-p20120502/msp430/lib > ls *.a
libc.a  libfp.a  libm.a  <<< I have 3 libraries
chrisc@SW20101105A:/cygdrive/c/mspgcc-20120406-p20120502/msp430/lib > ../../bin/msp430-nm libc.a | grep errno
errno.o:
00000002 C errno  <<< the 'C' means it's defined here
         U errno  <<< the 'U' means it is needed here
         U errno
chrisc@SW20101105A:/cygdrive/c/mspgcc-20120406-p20120502/msp430/lib > ../../bin/msp430-nm libm.a | grep errno
         U errno  <<< the 'U' means errno is needed here
chrisc@SW20101105A:/cygdrive/c/mspgcc-20120406-p20120502/msp430/lib >
If the above doesn't work out for you, or you are lazy / buzy, you can always try and add

int __errno;
to your code. Or may be it's short __errno, etc.
 
I hope someone w/ more knowledge will add answer to your question.
 
 
Link to post
Share on other sites

The issue is the link order. The linker places -lc before -lm and should be the reverse.

I have fixed this in the sources of Energia and it will be available in the next release. Unfortunately that means that you will have to link manually until a new release comes out. You can link manually by looking at the output of energia and look for the line in which all gets linked together. Copy / paste that line into a dos command window. Now look for -lc -lm on that line and reverse them line so -lm -lc and hit enter. You should now have the .elf file.

Link to post
Share on other sites

The following is a hack to work around this. This does not require linking manually:

 

Create a now tab and call it hack.c and put the following line in it:

int __ernno;

In the main Sketch under #include <Wire.h> put

extern int __errno;

then as the first line in setup() put:

  __errno = 0; 

There is probably a more elegant way around this but this does the trick as a dirty hack.

Link to post
Share on other sites

 

Hello, i am having problems with math library using energia. I always keep getting thi s error. I dont know whats wrong.

 

Error  : http://pastie.org/8127090

 

Here you can read the source : http://pastie.org/8127093#871-872

 

I highlighted the lines which are makeing troubles. Its lines 871 and 872, by commenting them you can avoid getting this error.

float accel_angle_y = atan(-1*accel_x/sqrt(pow(accel_y,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
float accel_angle_x = atan(accel_y/sqrt(pow(accel_x,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
 

you might try atanf, sqrtf and powf. That will let the compiler use the hardware floating point instructions instead of the software ones you get when using a double. math functions using a double can't take advantage of the hardware floating point.

Link to post
Share on other sites
  • 3 weeks later...

Hi,

 I have got some error with the pow() function in energia

the error says "undefined reference to 'pow' "

 

 

And  my piece of code is here

 
 
1)  float calcAltitude(float pressure){
2)  float a = (pressure*10)/101325;
3)     float k = 1.009876; 
4)  double n = pow (a , k);
5)  }
 
 
the error shows it in the 4th line.....
 
Can somebody help me out.....I am using energia0101E0009 in windows 7 
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...