How To Create A Static Library (.a) from an Existing Project MCUXpresso

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

How To Create A Static Library (.a) from an Existing Project MCUXpresso

2,732 Views
rcusack1
Contributor I

Hello, I have an existing project in MCUXpresso that I would like to create a static library (.a) file from so that I can use the functions and libraries in a future project. I am not sure the best way of going about doing this. I have seen people make static libraries and then link them in other projects in the past. Any guidance on how to do this would be appreciated. Thank you,

Labels (1)
0 Kudos
10 Replies

1,607 Views
Tirumalasetty
Contributor I

Hi,

I also have the same requirement, I have a project and it has built and created .bin file. Now, my requirement is to built the project to static library instead of .bin(executable). I have tried the above steps. Project>Properties>c/c++ General>settings and change the build artifact to Shared library from Executable. Still, it's generating only (.bin) not the shared library.

IDE: MCU Expresso

Please suggest me the steps to create a shared library / static library using my existing project.

 

Thanks in advance.

0 Kudos

1,598 Views
ErichStyger
Senior Contributor V

a static library (archive) is very different from an application (application entry point, startup, etc). Changing this 'in place' is possible, but you have to know 100% what you are doing.

What I recommend is

a) create a new project with the IDE (here you have the option to select to build a static library)

b) then copy/move over your files you want to have in the library.

I hope this helps,

Erich

0 Kudos

1,524 Views
Tirumalasetty
Contributor I

Hi @ErichStyger,

As per your comment I have created a "new C library project" for creating library. Later, I have copied all my .c files in source folder and .h folder in to include folder.

Now, if I build my project I was able to get the library. 50% of my requirement completed.

Another 50% is I have to copy a library file generated through some source files as part of my "C library project". Along with my own source and include files I need a library file also part of my project.

 

Thanks in advance,

Rambabu.

0 Kudos

1,515 Views
ErichStyger
Senior Contributor V

I'm sorry, but I don't understand what you mean?

Is it about how you can manage the library dependencies? Then have a read at https://mcuoneclipse.com/2017/09/19/managing-project-and-library-dependencies-with-eclipse-cdt/

Is it about how to link with a library? Then have a read at https://mcuoneclipse.com/2017/07/23/how-to-use-custom-library-names-with-gnu-linker-and-eclipse/

I hope this helps,

Erich

1,504 Views
Tirumalasetty
Contributor I

I have a requirement to link a already generated library file(sum.a) to a newly created library project(new_library_project). Once I build this library project(new_library_project) I will get a output library file(new_library_project.a), which should have the contents of old library file(sum.a).

Hope this is clear.

Thanks in advance.

0 Kudos

1,513 Views
Tirumalasetty
Contributor I
I have a requirement to link a already generated library file(sum.a) to a library project(new_library_project). Once I build this library project(new_library_project) I will get a output library file(new_library_project.a), which should have the contents of old library file(sum.a).

Hope this is clear.

Thanks in advance.
0 Kudos

1,505 Views
ErichStyger
Senior Contributor V

if you want to combine two archives into one, use this:

ar -rcT libA.a libB.a libAplusB.a

0 Kudos

1,522 Views
Tirumalasetty
Contributor I
How to keep A library file inside a library project.
0 Kudos

2,534 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ryan,

 

I think the following document will help you.

 How to create and use static library in MCUXpresso IDE 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,534 Views
rcusack1
Contributor I

I also want to add that I have tried going to Project > Properties > C/C++ General > Settings and change the build artifact, but the only artifact types available are Shared library and Executable

0 Kudos