Bulding a static library with CodeWarrior for Microcontrollers (Classic IDE)

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

Bulding a static library with CodeWarrior for Microcontrollers (Classic IDE)

Jump to solution
975 Views
eisenrah
Contributor I

Hello,

 

I developed a firmware containing many generic functions on a HCS08 microcontroller using CodeWarrior for Microcontrollers (Classic IDE) Version 6.3.

It would be very nice to precompile certain modules and supply them as a static library to customers, so that they can compile own C code against this API without seeing the source code.

Could you tell me how to 1.) build a static library in CodeWarrior and 2.) include it into a CodeWarrior project so that the linker will find it?

 

Thank you very much,

Friedemann

Labels (1)
0 Kudos
1 Solution
639 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

you can use Codewarrior create your own lib file. To create .lib file, you need follow the steps below.(please also refer the attached mylib project)

  1. Create one project with wizard.(I use QG8 as target chip)
  2. change the file name main.c as the lib name (in sample is mylib.c)
  3. define the lib functions in mylib.c
  4. add header file mylib.h in the project, and declare the prototype of the lib functions in it.
  5. add “#include mylib.h” in  mylib.c
  6. delete the following files from the project: start08.c, derivative.h, *.prm, MC9S08QG8.h, MC9S08QG8.c, ansiis.lib.c
  7. Press ALT+F7, in “Target Setting”, select “Libmaker for HC08” as Linker in the second droplist. In “Libmaker for HC08”, name your Library Filename.(the sample use mylib.lib), Click OK to close this window.

The following is how to use the lib file in the project:

  1. copy “mylib.lib” and “mylib.h” to your current project folder.
  2. import “mylib.lib” and “mylib.h” in your current project
  3. add “#include "mylib.h"”in the main.c file
  4. then you can use the lib functions in your current project code.

can it help you?


Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
640 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

you can use Codewarrior create your own lib file. To create .lib file, you need follow the steps below.(please also refer the attached mylib project)

  1. Create one project with wizard.(I use QG8 as target chip)
  2. change the file name main.c as the lib name (in sample is mylib.c)
  3. define the lib functions in mylib.c
  4. add header file mylib.h in the project, and declare the prototype of the lib functions in it.
  5. add “#include mylib.h” in  mylib.c
  6. delete the following files from the project: start08.c, derivative.h, *.prm, MC9S08QG8.h, MC9S08QG8.c, ansiis.lib.c
  7. Press ALT+F7, in “Target Setting”, select “Libmaker for HC08” as Linker in the second droplist. In “Libmaker for HC08”, name your Library Filename.(the sample use mylib.lib), Click OK to close this window.

The following is how to use the lib file in the project:

  1. copy “mylib.lib” and “mylib.h” to your current project folder.
  2. import “mylib.lib” and “mylib.h” in your current project
  3. add “#include "mylib.h"”in the main.c file
  4. then you can use the lib functions in your current project code.

can it help you?


Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

639 Views
inside_system
Contributor II

thank you very much zang jennie, thats waht i excatyl want ,,thanks

0 Kudos
639 Views
eisenrah
Contributor I

Exactly what I need.

Perfect, thanks a bunch! :smileyhappy:

0 Kudos