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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
10,089 Views
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.

Labels (1)
0 Kudos
Reply
1 Solution
10,028 Views
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 )

View solution in original post

5 Replies
10,025 Views
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 Kudos
Reply
10,028 Views
ErichStyger
Specialist I

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

0 Kudos
Reply
10,028 Views
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 Kudos
Reply
10,029 Views
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 )

10,028 Views
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