Link Error: Undefined: "itoa" ?

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

Link Error: Undefined: "itoa" ?

Jump to solution
2,250 Views
dmarks_ls
Senior Contributor I

So, I've inherited a massive project from a prior contractor.  The project was previously built in CW 7.1, targeted for a MCF52233.  I've managed to cull all the warnings and errors (save one), but while trying out fixes for the one error, I discovered that the linker is having issues.  Specifically, it's telling me that "itoa" is undefined, three times (it's referenced in three different functions).  No other linker errors appear.  I'm now using CW 7.2.1.  Any ideas on where I should start looking to resolve the error?  Hoping it's just a matter of including an additional library in my build.  Thanks.

Labels (1)
0 Kudos
1 Solution
653 Views
CrasyCat
Specialist III

Hello

 

According to the EWLCReference.pdf manual, itoa is part of the EWL Extras Library.

So you need to re-generate the libraries and enable EWL Extras library functions.

 

Please refer to EWLCReference.pdf, chapter Configuring EWL, section Configuring the EWL Extras Library for information on how to achieve that.

 

CrasyCat

View solution in original post

0 Kudos
4 Replies
654 Views
CrasyCat
Specialist III

Hello

 

According to the EWLCReference.pdf manual, itoa is part of the EWL Extras Library.

So you need to re-generate the libraries and enable EWL Extras library functions.

 

Please refer to EWLCReference.pdf, chapter Configuring EWL, section Configuring the EWL Extras Library for information on how to achieve that.

 

CrasyCat

0 Kudos
653 Views
dmarks_ls
Senior Contributor I

Well, that was definitely the right path to go down.  The PDF doesn't describe how to actually rebuild the libs, but it wasn't too hard to go find the EWL_C.CF.mcp project and perform a rebuild.

 

Unfortunately, I've now opened up a whole can of worms.

 

First, you have a documentation bug.  In the PDF/CHM, you state: "Use the EWL_NEEDS_EXTRAS macro to specify whether or not EWL should extend its standard behavior with the facilities that EWL Extras provides."

 

The correct macro is _EWL_NEEDS_EXTRAS, not EWL_NEEDS_EXTRAS.

 

Once I figured that out and inserted that macro (defined as 1) into lib_ewl.prefix, I tried rebuilding the EWL libs, but I got 64 errors for each of the 8 libc modules, all saying "the file 'extras_stdlib.h' (or extras_string.h) cannot be opened".  So it was necessary to add {Project}include\extras to Access Paths for each configuration.  CodeWarrior being CodeWarrior, the simplest way to do this was to add extras.h to the build, which then automatically adds that path to each build, then remove extras.h from the build.

 

However, I was still getting a linker error on itoa in my app.  Looking closer, I found that itoa() resides in extras.c, and extras.c is not a part of the EWL_C.CF.mcp project.  So, I added extras.c to the v(2/3/4)_libc and v(2/3/4)_libc99 builds, rebuilt EWL again, then rebuilt my app.  Big mistake apparently, as I now get 589 link errors in my application, all following this pattern:

 

Link Error : Illegal 16-bit PC relative reference to symbol '_my_function'

from address 0x00017576(<-- varies) in section '.text' of file 'my_source_file.c'.

This type of reference has a range from 4294934528 to 32767 bytes.

 

FWIW, 4294934528 is just -32768 sign-extended and unsigned.  Of note, the three linker errors about itoa() are not present in this list.  If I remove extras.c from the EWL build, rebuild EWL, and rebuild my app, the 589 errors go away, and I'm just left with the three itoa() errors.

 

So, what am I doing wrong?

0 Kudos
653 Views
dmarks_ls
Senior Contributor I

OK, update... looks like the steps I took to include extras.c into the EWL build were successful, and that the 592 errors I'm getting are from the next stage of the linker (my guess is, this code is probably being built for too small a memory model).  So, in essence, it worked.  In summary:

 

1) The documentation lists the wrong macro to enable for building in extras (missing leading underscore).

2) The documentation does not discuss how to actually perform the rebuild under CodeWarrior.  It would be extremely useful to briefly describe locating the EWL_C.CF.mcp file and adding extras.c et al to the C and C99 build targets.

 

Thanks for the help.

0 Kudos
653 Views
J2MEJediMaster
Specialist I

 You need to file a service request to report the error in the documentation, so that others do not get tripped up on this issue as well. Click here to file a service request. Pick the category Software Product Support.

 

---Tom

0 Kudos