Share constants beetween a library and an application

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

Share constants beetween a library and an application

跳至解决方案
2,761 次查看
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,714 次查看
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,727 次查看
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,715 次查看
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,696 次查看
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,753 次查看
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