Can not link libraries with MC9S12E128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can not link libraries with MC9S12E128

Jump to solution
4,270 Views
marcoB
Contributor I
I am having a lot of trouble linking a library to my program.
I am trying to make use of the math.h library, but I can not get access to it.
I am trying to test this using a simple program:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12e128.h>     /* derivative information */
#include <math.h>
#pragma LINK_INFO DERIVATIVE "SampleS12"
double result;
void main(void) {
result = sqrt(4);
 EnableInterrupts;
 for(;:smileywink: {} /* wait forever */
}
At first I thought all you needed was the #include, then found out more needs to be done, and I can't seem to figure it out. I tried adding the math.h file to the libraries folder in the project, I also gave it high priority on the link order. I have been also fooling around with Command line arguments, but I do not know much about them. I have been searching for a solution to this for a long time and can not find it anywhere.
The specific error I get is:
Link Error: L1822 Symbol sqrt in file main.c.o is undefined
Link Error: Link failed
I also attached to this post, the zipped project file if that is needed.
Someone please give me a hand on this, I'm stumped! thank you,
           -mark
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,159 Views
BlackNight
NXP Employee
NXP Employee
Hello,
your problem is that during project creation, you decided to use compiler settings/libraries with integral support only? So no float and doubles. You probably did this by mistake.
That's why your library in the project (ansibi.lib, the 'i' at the end of the name stand s for 'integral only') does not contain any floating point support, like 'extern double sqrt (double x)'.
You could now change the library, change the compiler options/etc, but this is more for an expert and if you know what you are doing. The easiest for you is probably run through the wizard again.
If you create a project with the project wizard, then around step 6 the wizard asks you if you want to use any floating point support: you need to select support for floating point (either IEEE32 or IEEE64).

PS: The reason for having an integral library is simply because of code density for several library functions: mainly printf(). If printf()/etc does not need to support the floating point formats, the code will be much more efficient and smaller.

Hope this helps.

Regards,
Erich

View solution in original post

0 Kudos
Reply
3 Replies
1,160 Views
BlackNight
NXP Employee
NXP Employee
Hello,
your problem is that during project creation, you decided to use compiler settings/libraries with integral support only? So no float and doubles. You probably did this by mistake.
That's why your library in the project (ansibi.lib, the 'i' at the end of the name stand s for 'integral only') does not contain any floating point support, like 'extern double sqrt (double x)'.
You could now change the library, change the compiler options/etc, but this is more for an expert and if you know what you are doing. The easiest for you is probably run through the wizard again.
If you create a project with the project wizard, then around step 6 the wizard asks you if you want to use any floating point support: you need to select support for floating point (either IEEE32 or IEEE64).

PS: The reason for having an integral library is simply because of code density for several library functions: mainly printf(). If printf()/etc does not need to support the floating point formats, the code will be much more efficient and smaller.

Hope this helps.

Regards,
Erich
0 Kudos
Reply
1,159 Views
marcoB
Contributor I

ok, thanks for that tip....looks like its gotten me somewhere possibly.
I'm now getting a different error:

Link Error: L4025: This limited version allows only 1024 bytes of code.
Link Error: Link failed 

So by the looks of it, I dont have the full version. I believe I download a student version (as I am a student working on my final year project). Would an upgrade involve any cost? If so, I dont have any budget at all:smileyindifferent:
Unless theres another way around this. I used the same code I mentioned before, and all the same settings except for the support for floating point, and I tried both 16 and 32. thanks,
         mark

0 Kudos
Reply
1,159 Views
marcoB
Contributor I
ok...i got it working!!!
thanks for the help, i really appreciate it.
        Mark
0 Kudos
Reply