Creating libraries and hiding code

Hi

With GCC, it seems to work perfectly. Managed to build a library and use it in another project.
I cannot get it to work with ARMC6.

@arekzaluski not sure if you found the same issue as I did with ARMC6 ?

Nick

Hello,

@noutram have you succeed to generate library with ARMC6? I am trying to build it and have similar problem:

Is it even possible to do it with ARMC6 in Mbed Studio?

Michal

Hello. The question is already old but I hope this answer can help other people in the future.

Yes it is possible. Before switching to mbed studio, just a couple weeks ago, I was using VsCode with mbed cli. If you installed mbed studio by adding mbed cli to the system environment paths (you have to check the checkbox at a certain step of the installation as far as I remember) you can run mbed cli commands in the command prompt in Windows. Remember that the current version (1.4.4 as of 15.06.2022) comes with mbed cli1.

I am using GCC_ARM. But I tried with ARMC6 by running mbed compile -m PROTO_F407 -t ARM --library in the cmd prompt. I got this error message at the end of the compilation:

[Error] @0,0: L9940E: This variant of Arm Compiler is licensed only for use with Mbed Studio

However, I got the *.d and *.o files in libraries folder under ./BUILD directory. I replaced one of my modules (e.g., Encryption) with the corresponding folder in libraries just for trying to compile the code. It compiled but at the end of the compilation the linker was not able to link the object files and I did not get the binary file. I believe it happened because of the library compilation has not ended with success. I think it would work if you install ARM compiler seperately and set the correct executable path as the global config.

Here the trick is doing it in the command prompt. Even you use mbed studio, you have to do this in the command prompt by using mbed cli. Mbed studio is not configured to compile libraries by default. But you can add this fuctionality by creating your custom build profile.

As I said, I am using GCC_ARM as the compiler. So, I installed GCC_ARM (q4-major) and modified external-tools.json as explained here. Then, I simply run mbed compile -m PROTO_F407 -t GCC_ARM --library in the cmd. This works perfectly. I already provided my source code to some of our external collaborators with those libraries.

Even you use mbed studio, I believe you still have to be comfortable with Linux terminal and Windows cmd prompt because mbed studio is running mbed cli in the back end and you have to be familiar with the mbed cli commands. I was comfortable with VsCode. But debugging the fw with VsCode is very painful and not practical. I switched to Mbed studio for this reason.

I did not try mbed studio on Ubuntu but it should be easier.

3 Likes

Hi @hckar,

Thanks for your response. I’ve tried your proposed methods and came up against two complications:

  1. When I include the resulting library in Mbed Studio, it still fails at the Linker. I’ve tried several ways of including the library - including pulling an image from Git (which works for other libraries on Mbed, modifying the mbed_app.json, etc…). I’ve checked the lib.a and all symbols are included… just doesn’t seem to link.

  2. The resulting library is 45MB, when it should be a few KB. How did you prevent the build from including Mbed-OS files (these are what is making my lib.a so large).

Thanks for any guidance you can provide!

Regards,

Mark