Brian Carroll

Using libraries in CW6.2 for Coldfire

Discussion created by Brian Carroll on Jan 15, 2010
Latest reply on Feb 9, 2010 by Brian Carroll

Hi all,

I'm using CodeWarrior 6.2 with the MCF51QE128.


In my application, I want to use some functions from an existing C source library. I've managed to compile the library (first time for me), and call the specific functions I need from my application. When I compile the application, it works OK, but the entire library seems to end up inside my processor. This wastes a huge amount of flash space that I will need to use for other code later.



Does anyone know how to get CodeWarrior to remove the unused parts of the library? (I thought this would happen automatically if I created a library, that's why I did it that way...)


What I did: 

I created two projects: one to compile the library and the other for my application. 


To compile the library, I imported all the source files into the project. Then I went to

"Targets" panel -> Standard -> Coldfire Target

and changed the Project Type to "Library", and gave it a name like mylib.lib

At this stage I hit the "Make" button. It all compiled OK and the .lib appeared. Good!


Then I created a separate project for the application. I wrote a "main" routine to call the functions I need. Then I went to the "Libs" section of the "Files" tab and added the .lib file.


When I "make" the application project and download it into the processor, it tells me it is transferring 117kB. This is roughly the amount of code in the full library. Am I doing something wrong? I really hope I don't have to restructure or rewrite parts of the library by hand!