Arm Mbed OS support forum

How can my library detect when it is being compiled using the mbed [online] compiler?

I test imported one of my libraries from github, which went fine, but I would like to configure it for MBED CLI/ MBED online compiler, so that it works straight away without modifications. (Meanwhile I had to create a #define MBED_ONLINE_COMPILER and put that in a config.h file to configure my library)

I would like for example to disable exceptions and RTTI automatically when using mbed online compiler. Is there a define that can be used to detect that I am compiling under MBED CLI/ MBED online compiler

e.g like _linux_ _WIN32 etc ?

Thankyou.

Hello Andy,

I think generally you can test for __MBED__ .
If you’d like to know which version
MBED_VERSION
MBED_MAJOR_VERSION
MBED_MINOR_VERSION
MBED_PATCH_VERSION
MBED_VERSION_CHECK
could be handy. For more details have a look at “mbed-os\platform\mbed_version.h

1 Like

Hello,
I would like to ask a question. The static library libmbedtls.a I compiled is 64bit, but I need 32bit on my device. I downloaded the latest version 2.16.6. What is the reason? Is the version I downloaded wrong?

Hello ZHANGJIE,

If you cross compile on a 64bit system (Linux, Windows, Mac) for Mbed then you should tell the make utility program to use the ARM compiler rather than the default 64bit compiler.
For example, if the GCC-ARM compiler is located in the

/opt/gcc-arm-none-eabi-9-2019-q4-major/bin

folder then try to run make as

make CC=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc

Best regards,

Zoltan