Share constants beetween a library and an application

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Share constants beetween a library and an application

ソリューションへジャンプ
2,742件の閲覧回数
Davidino
Contributor IV

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 件の賞賛
返信
1 解決策
2,695件の閲覧回数
Davidino
Contributor IV

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!

元の投稿で解決策を見る

4 返答(返信)
2,708件の閲覧回数
ErichStyger
Specialist I

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 件の賞賛
返信
2,696件の閲覧回数
Davidino
Contributor IV

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!

2,677件の閲覧回数
ErichStyger
Specialist I

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 件の賞賛
返信
2,734件の閲覧回数
ErichStyger
Specialist I

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