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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jump to solution
300 Views
Contributor III

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.

Labels (1)
0 Kudos
1 Solution
239 Views
Senior Contributor II

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 )

View solution in original post

5 Replies
236 Views
Contributor III

Thanks @ErichS @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 Kudos
239 Views
Senior Contributor II

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

0 Kudos
239 Views
Contributor III

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 Kudos
240 Views
Senior Contributor II

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 )

View solution in original post

239 Views
Senior Contributor III

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