Create/Using Libraries with CodeWarrior/CF5282

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

Create/Using Libraries with CodeWarrior/CF5282

7,451 Views
dmuller
Contributor I
Hello

How can I create my own library with the CodeWarior and how can I add it to a project?
Labels (1)
0 Kudos
10 Replies

1,722 Views
CrasyCat
Specialist III

Hello

In order to generate a run time library:

 - Create your project as usual.
 - Open the target setting dialog (pressing ALT + F7)
 - Go to the "Coldfire Target" panel
 - Change Project Type to "Library" and adjust the name of the File Name edit
   box.
 - Close the dialog clicking on OK.

That should do it.

To add the library to your project:
 - Click with the right mouse button in the project (.mcp) window
 - Select "Add Files" and browse for your library file
 - Select he file and click on Open. The file is added to the project.

I hope this helps.

CrasyCat

0 Kudos

1,722 Views
softsmit
Contributor I
Hi CrazyCat, I'm new to Codewarrior. 
 
I made a surce code for use FlexCan on an MCF5235 evaluation board. 
Now i have to create a portable library with this code. 
 
I try to do it but i've occured on some problems: 
There is a function called CMS_Write in the library, but when i call it in the main and i try to debug an error appears: 
"link error: Undefined: cms_var                               " 
"Referenced from CMS_Write in FlexCan_LIB.a    "

cms_var is declared in an header file in the library project.

Can you tell me what's wrong?
bye!


0 Kudos

1,722 Views
CrasyCat
Specialist III
Hello
 
I suspect you are missing a proper definition of the variable somehow.
 
An external declaration is not enough.
 
Anyway this needs to be investigated carefully.
 
I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

Attach the generated .zip file to the SR.
CrasyCat
0 Kudos

1,722 Views
dmuller
Contributor I
Hello CrasyCat

-I generated a library called Test_Lib.a
-the library contains a function called "add"

-I added the library to the project
-in the main I use the function add
-if I want to compile or link the project
an error: "undefined identifier 'add'" appears.

Its neccessary to include a header file if I use librarys?
How does it work?
Its neccessary to call the library with extension *.a or can I use the extension *.lib or any other extension?

Thanks, Dani
0 Kudos

1,722 Views
CrasyCat
Specialist III

Hello

Yes you need to include a header file with declaration of object and prototype of the function from the library.

This follows the standard ANSI C programming rules. If you want to use the function strcpy from the ANSI library you have to include the files string.h first :smileyhappy:.

Library can have any extension, but I would recommend to use extension .a .

Using another extension than .a  will require an extension of the File Mappings associated with the project. You need to define the new extension there and tell the IDE what it is supposed to do with the files :smileyhappy:

CrasyCat

0 Kudos

1,722 Views
dmuller
Contributor I
Hello

Ok, I included the header file: #include .
The Function in the library is called "add(int value1, int value2)"
In the main I use the function "add".

I can compile it with no error.
Linking generate an error: "Link Error: Undefinded: 'add(int, int)'"
Link failed.

What going wrong?
0 Kudos

1,722 Views
CrasyCat
Specialist III
Hello
 
  Probably taht the library file (.a) has not been added to the project.
 Or that the function name in the library is different.
 
CrasyCat
0 Kudos

1,722 Views
dmuller
Contributor I
Hello CrazyCat,
It works now - it was a problem, that the application was builded with the c++ compiler and the lib with the c-compiler....
Thank anyway.

But another question:
Is it possible to step into the library during debugging - and see the source code?
0 Kudos

1,722 Views
CrasyCat
Specialist III
As long as you make sure that you generate debug info for the source files in the library you should be able to debug the functions located there.
 
If you have a dot next to a source file in the column with the green bug on the top, you are generating debug info (See bitmap).
 
 
CrasyCat
0 Kudos

1,722 Views
dmuller
Contributor I
Hello

Thank you very much, you help me a lot, it works!

Best Regard, Daniel
0 Kudos