Arm Mbed OS support forum

Mbed cli2 does not allow compiling Mbed6 Ethernet example

Hi all,
I fail to compile example code from Mbed6 documentation with mbed cli2:

Following the guideline in I started with:
mbed-tools new ethernet_test

Then, I switched to the directory ethernet_test and replaced the default main.cpp by the example code taken from, see the code for main.cpp at the bottom.

In the next step, I configured my little project for FRDM K64F board with ARM_GCC toolchain:
mbed-tools configure -m K64F -t GCC_ARM

and attempted to compile the code:
mbed-tools compile -m K64F -t GCC_ARM

Unluckily, the compilation failed with the error:
…/…/…/…/main.cpp:6:10: fatal error: EthernetInterface.h: No such file or directory
6 | #include “EthernetInterface.h”

Is there anything else I need to take care of?

I noticed the mbed-tools complained about missing modules “prettytable”,“intelhex”,“jinja2”,“python3”, but did not abort the execution. Well, prettytable and intelhex are actually available, but I guess / hope that this is not related to the issue.


You need to add mbed-netsocket in your CMakeLists.txt

target_link_libraries(${APP_TARGET} mbed-os mbed-netsocket)

The complete example project is here:

many thanks - but, I need to write that the compilation again failed. But this time it seems to be an error in the mbed-os sources:

 ./../../../mbed-os/connectivity/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/supp_gkh_sec_prot.c: In function 'supp_gkh_sec_prot_message_get':
../../../../mbed-os/connectivity/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/supp_gkh_sec_prot.c:180:57: error: expected ')' before 'PRId64'
  180 |                 tr_error("GKH: invalid replay counter %"PRId64, eapol_pdu->msg.key.replay_counter);

If I download the referenced example, I face a similar failure:

In file included from ../../../../mbed-os/connectivity/libraries/nanostack-libservice/./mbed-client-libservice/ns_trace.h:32,
             from ../../../../mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_management_api.c:38:
../../../../mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_management_api.c: In function 'thread_management_set_commissioning_data_timestamp':
../../../../mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread/thread_management_api.c:401:63: error: expected ')' before 'PRIu64'
  401 |     tr_debug("thread management set commissioning timestamp %"PRIu64, time);
  |                                                               ^~~~~~

If you or anyone else has an idea how to proceed with these issues, this would be highly appreciated!
Best regards

At least I found a workaround which does not make me happy, but it works.
I added some definitions in the CMakeLists.txt file in the root directory:

  • For C++ files, I added:
  • For C files, I added
    add_compile_definitions(PRIx64="llx") add_compile_definitions(PRId64="lld") add_compile_definitions(PRIi64="lli") add_compile_definitions(PRIu64="llu")

Well, the definitions for C anyway also affect the C++ compilation, so the definition for C++ is in the end superflous.

Hi cdelfs,

I don’t reproduce the error with the mbed-os-example-sockets example project.
Which version of the GCC are you using?

My build tools are below:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

$ mbed-tools --version

$ python --version
Python 3.9.5

$ cmake --version
cmake version 3.20.0-rc5

many thanks for your hint with the compiler version. I can confirm: this was the reason!!

So far, I used the arm-none-eabi-gcc which was directly installable via apt-get/aptitude (on my Ubuntu 20.04 LTS). I was aware that Ubuntu is not a “front runner” when keeping up with most recent SW versions of the available packages, but I did not expect that the compiler was not usable for mbed.
Here my previous version :

$arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

After installing the most recent version:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release)

the issue went away and I could - without further hacks in the CMakeLists.txt file - compile the example program!

I also updated the mbed-tools (from 7.14 .0 to 7.18.0), needed to keep my Python version (3.8.5) and left my recent cmake install untouched (3.20.2). But these differences were not decisive.

I checked the release notes for the most recent mbed-os release and also found

In the mbed OS 6.11.0 release. we are testing the following toolchains:

  • ARM compiler 6.15.0
  • GCC_ARM 9-2019-q4-major

which confirms that the standard Ubuntu compiler version is not appropriate - even though the version seems to be similar to the version used by mbed/you (both based on 2019-q4) :wink: .

Again, many thanks MACRUM for providing the hint!
Best regads