How to link one static library(.a) to another static library(.a) in mcuxpresso

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

How to link one static library(.a) to another static library(.a) in mcuxpresso

跳至解决方案
12,090 次查看
jayesh_joshi
Contributor IV

Hi,

I want to create a two-level library development in #mcuxpresso. One library which contains a lower level of APIs and second above that use of this API and use as a superset of both library. Now I am able to create library both library file but I am unable to link first .lib with second .lib.

Thanks in advance.

标签 (1)
0 项奖励
回复
1 解答
12,029 次查看
ErichStyger
Specialist I

The easiest way is really if you build a library with all the object files. As pointed out by the Stack Overflow article of Con Verse, you can use ar to combine libraries but this is not straight forward. The easiest way is using 'thin' libraries (option T) but this requires the object files accessible. Or use the libtool (GNU Libtool- GNU Project - Free Software Foundation )

在原帖中查看解决方案

5 回复数
12,026 次查看
jayesh_joshi
Contributor IV

Thanks @ErichStyger @converse  for the response.

Right now I have solved the issue by adding all source files to my library project. So Now all the object file creates one single lib(.a) file. I have not looked into linking the binary as that looks also promising. 

 

0 项奖励
回复
12,029 次查看
ErichStyger
Specialist I

try swap the order of the two libraries (link order).

0 项奖励
回复
12,029 次查看
jayesh_joshi
Contributor IV

Thanks, ErichS‌ for response.

Yes, I understand we could include 2 lib files in the application project and these two libs can communicate with others in the application project. But my objective is to create one lib project which includes a previously build the library. And include only one lib to the application project.

Regards.

0 项奖励
回复
12,030 次查看
ErichStyger
Specialist I

The easiest way is really if you build a library with all the object files. As pointed out by the Stack Overflow article of Con Verse, you can use ar to combine libraries but this is not straight forward. The easiest way is using 'thin' libraries (option T) but this requires the object files accessible. Or use the libtool (GNU Libtool- GNU Project - Free Software Foundation )

12,029 次查看
converse
Senior Contributor V

A library is not 'linked' it is just a collection of object files inside a container file - its a little like a zip file. The archive utility (ar - arm-none-eabi-ar) is used to create a library.

See ar - GNU Binary Utilities 

You can merge to libraries

linux - How to merge two "ar" static libraries into one? - Stack Overflow 

Note that the ar utility is called arm-none-eabi-ar