Adding library with hidden code using ARMC6

Hello,

I am trying to add 3rd party library, which has hidden code. I’ve got header files and files with .lib extension. Im using Mbed Studio with tool version shown below:
image

Target: NUCLEO_L476RG
Toolchain: ARMC6
3rd party library:
image

When I add this to my project, library appear but got comunicat " Failed to parse the .lib file"

Program does not compile:

What might be a problem? Is it even possible to add .lib file that way?

Kind regards,
Michal K.

Hi,

AFAIK, library extension should be .a for GCC and .ar for ARMC6.

Thanks,
Toyo

Hi Michal,

It looks like there are two things going on here:

  1. Mbed Studio’s library widget is incorrectly treating the .lib files as Mbed library references, leading to the “failed to parse .lib file” error.
  2. The program is failing to link due to undefined symbol.

To fix the first issue, you could try renaming the .lib files to .a so they are not picked up by the library widget.

The second is more complex. It should be possible to link to a static library like this. Some thoughts:

  • Are the libraries built with Arm Compiler 6 for the NUCLEO_L476RG target?
  • Is the undefined symbol init_iaq_2nd_gen defined in one of the libraries?
  • You could try using mbed CLI to compile the project instead. See for example this thread: Include .a file during compilation - Question | Mbed.

To debug further, is it possible to share a minimum project that reproduces this issue, including the libraries?

Some links:
https://developer.arm.com/documentation/dui0476/m/Overview-of-the-ARM-Librarian-topics/Considerations-when-working-with-library-files
https://developer.arm.com/documentation/dui0803/k/Image-Structure-and-Generation/Specifying-user-libraries-when-linking?lang=en

Thanks,
Matt

Hello,
I’ve tried to change .lib file to .ar and Mbed Studio library widget don’t see it (which I think is good), but linker can’t link functions correctly. Please see the result below:

I also tried to compile it like this:

mbed compile -t ARMC6 -m NUCLEO_L476RG --source=. --source=.\ZMOD4XXX\IAQ

Got this result (I’ve tried with .ar and .a extension of .lib file):

Inside the lib_iaq_2nd_gen file I can see, that it was compiled with :ARM Compiler 6.14.1 Tool: armclang [5db08000]:


but the Mbed Studio ARMC6 compiler is a newer version:
Product: ARM Compiler 6.16 for Mbed Studio
Component: ARM Compiler 6.16
Tool: armar [5dfea700]

I also tried to simply create a library with ARMC6 (.ar file) for a simple .cpp file and got build failure:

mbed compile -t ARMC6 -m NUCLEO_L476RG --library --source . --source LIB

Could the problem be incompatibility in the compiler version?

I also tried to simply create a library with ARMC6 (.ar file) for a simple .cpp file and got build failure

It looks like the library build failed due to a license problem with armar. The Arm Compiler version shipped with Mbed Studio is only licensed for Mbed Studio use cases, and it looks like this use of armar is blocked. I’ll pass this on to the team to hopefully unblock this in future releases.

Could the problem be incompatibility in the compiler version?

You might make progress by changing the options passed to the compiler when you build your project. In particular, disabling short-enums and short-wchar. See Documentation – Arm Developer.

That’s because the linker is complaining that the size of enums and wchart are different in the library and application code.

You can do this in Mbed Studio by setting up a custom build profile, see Building and running a program - Building and running a program | Mbed Studio Documentation.

Could you help me with an example how and where I can prepare a user-defined profile? Or which file I should modify?
Can I modify “profile.json”?

@mgordon01 I finally managed to compile this library with ARMC6 - your tips were useful.
image
image

Thank you.

Michal Kozlowski

1 Like

Hi, were you able to get the zmod4xxx driver working? Currently, I’m in a state where everything compiles but the Renesas driver seems it does not work properly. Would you be open to share some implementation details?

Thank you