Share constants beetween a library and an application

cancel
Showing results for 
Search instead for 
Did you mean: 

Share constants beetween a library and an application

Jump to solution
74 Views
Davidino
Contributor III

Goodmorning,

I'm trying to divide my project into two parts: a library (which contains the code that I rarely change) and an application (that I often change and calls library methods).
Besides I need that some constants can be shared beetween the library and the application with a common header file and possibly, if I change the constant values contained in this header file, I'd like to avoid recompiling the library each time.

I know that something like that is possble with Microchip MPLABx: https://www.microchip.com/forums/m1092866.aspx

Is it possible to do the same with MCUExpresso?

Thank you.

0 Kudos
1 Solution
27 Views
Davidino
Contributor III

Hello @ErichStyger ,

thank you for your article and answer. I've just realized that you are the person that write all those good articles on mcuoneclipse!! It's an honour and a pleasure. I've recently find out about MCUExpresso Working Set following you indications, and others.

Concerning the library, I finished yesterday and it works! It's been a bit demanding because I had to convert a lot of #defines into consts and extern consts, so that library constants can be configured in the application.

For the library I've followed this one: https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Creating-and-Linking-to-Library-Projects/m-p/469212. Did you know it?
I had to start a brand new project since, as far as I understood, it's the only way to have a static library.

Davidino_0-1656050189622.png

Trying to change the Build Artifact for an existing project, the only possibilities are: Shared Library and executable.

However I'm going to read your article for checking how you would do it. Thank you again for your work, highly appreciate!

View solution in original post

4 Replies
40 Views
ErichStyger
Senior Contributor IV

Hi @Davidino ,

the following article might be of interest for you too:

https://mcuoneclipse.com/2022/06/21/tutorial-creating-and-using-rom-libraries-with-gnu-build-tools/

It is yet another way how to share things between an application and a library.

Erich

0 Kudos
28 Views
Davidino
Contributor III

Hello @ErichStyger ,

thank you for your article and answer. I've just realized that you are the person that write all those good articles on mcuoneclipse!! It's an honour and a pleasure. I've recently find out about MCUExpresso Working Set following you indications, and others.

Concerning the library, I finished yesterday and it works! It's been a bit demanding because I had to convert a lot of #defines into consts and extern consts, so that library constants can be configured in the application.

For the library I've followed this one: https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Creating-and-Linking-to-Library-Projects/m-p/469212. Did you know it?
I had to start a brand new project since, as far as I understood, it's the only way to have a static library.

Davidino_0-1656050189622.png

Trying to change the Build Artifact for an existing project, the only possibilities are: Shared Library and executable.

However I'm going to read your article for checking how you would do it. Thank you again for your work, highly appreciate!

9 Views
ErichStyger
Senior Contributor IV

Did you know it?

Yes, see as well https://mcuoneclipse.com/tag/libraries/

Thank you for your article and answer. I've just realized that you are the person that write all those good articles on mcuoneclipse!! It's an honour and a pleasure. I've recently find out about MCUExpresso Working Set following you indications, and others.

Thank you :-).

Erich

0 Kudos
66 Views
ErichStyger
Senior Contributor IV

Hi @Davidino,

Is it possible to do the same with MCUExpresso?

Short answer: yes.

Longer answer: yes, and that Microchip forum just describes a plain-vanilla approach with GNU tools and libraries. As said in that article: You just need to keep that .a file and .h file in sync: if you need to recompile the library or not, depends on your constant usage: if the constant change both for the library and the application, then of course you need to recompile it.

I hope this helps,

Erich