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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,108 次查看
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

标签 (1)
0 项奖励
回复
1 解答
772 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

3 回复数
773 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

772 次查看
inside_system
Contributor II

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

0 项奖励
回复
772 次查看
eisenrah
Contributor I

Exactly what I need.

Perfect, thanks a bunch! :smileyhappy:

0 项奖励
回复