Creating libraries

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

Creating libraries

Jump to solution
1,053 Views
juliancox
Contributor V

Can anyone direct me to a comprehensive set of instructions for creating libraries and using them in a project. I am using CW 11.1 for S08 processors. I have a number of projects, all of which have a significant amount of common source code. All the articles that I have found are VERY old (V5) and bear no relationship to the latest version.

0 Kudos
1 Solution
1,039 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.
  8. Compile again. In “bin” folder of the lib project, you could find the lib file named “mylib.lib”

 

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.

 

I hope this information is helpful to you.

 

Have a nice day,

Jun Zhang

View solution in original post

0 Kudos
1 Reply
1,040 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.
  8. Compile again. In “bin” folder of the lib project, you could find the lib file named “mylib.lib”

 

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.

 

I hope this information is helpful to you.

 

Have a nice day,

Jun Zhang

0 Kudos