4 years, 10 months ago.

How to export project from online compiler with latest or specified mbed os/libraries ?

I exported nucleo-mbed-rtos demo code via online compiler, and tried to get it compiled with GCC-ARM-Embedded V5.4, the latest version of GCC. I got the following errors.

In file included from ../mbed/./mbed.h:50:0,
                 from ../main.cpp:1:
../mbed/./CAN.h:235:21: error: field '_can' has incomplete type 'can_t {aka can_
     can_t           _can;
In file included from ../mbed/./CAN.h:23:0,
                 from ../mbed/./mbed.h:50,
                 from ../main.cpp:1:
../mbed/./can_api.h:55:16: note: forward declaration of 'can_t {aka struct can_s
 typedef struct can_s can_t;
../main.cpp: In function 'int main()':
../main.cpp:39:73: warning: format '%d' expects argument of type 'int', but argu
ment 2 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
         printf("SW2 was pressed (last 5 seconds): %d \n", button_pressed);
make[1]: *** [main.o] Error 1
make: *** [all] Error 2

I compared the mbed folder of nucleo-mbed-rtos with other projects, which can be built successfully with same compiler. They have some differences, but CAN related headers are identical.


It seems the error is introduced by

main.cpp -> mbed.h -> CAN.h

    can_t           _can;
    FunctionPointer _irq[9];

while there is a forward defintion in can_api.h

.\mbed/CAN.h:235:    can_t           _can;
.\mbed/can_api.h:55:typedef struct can_s can_t;
.\mbed/can_api.h:57:void          can_init     (can_t *obj, PinName rd, PinName td);
.\mbed/can_api.h:58:void          can_free     (can_t *obj);
.\mbed/can_api.h:59:int           can_frequency(can_t *obj, int hz);
.\mbed/can_api.h:61:void          can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id);
.\mbed/can_api.h:62:void          can_irq_free (can_t *obj);
.\mbed/can_api.h:63:void          can_irq_set  (can_t *obj, CanIrqType irq, uint32_t enable);
.\mbed/can_api.h:65:int           can_write    (can_t *obj, CAN_Message, int cc);
.\mbed/can_api.h:66:int           can_read     (can_t *obj, CAN_Message *msg, int handle);
.\mbed/can_api.h:67:int           can_mode     (can_t *obj, CanMode mode);
.\mbed/can_api.h:68:int           can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle);
.\mbed/can_api.h:69:void          can_reset    (can_t *obj);
.\mbed/can_api.h:70:unsigned char can_rderror  (can_t *obj);
.\mbed/can_api.h:71:unsigned char can_tderror  (can_t *obj);
.\mbed/can_api.h:72:void          can_monitor  (can_t *obj, int silent);

But I can not find can_s definitions anywhere. So I visited github for mbed libraries, and I found many can_s under architectures. For nucleo_F103, it should be placed at:


The objects.h is at /mbed/TARGET_NUCLEO_F103RB/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/objects.h,

The objects.h should be included via:

mbed.h -> CAN.h -> can_api.h -> device.h -> objects.h

Then I found the github version of objects.h is quite different from exported one. Then I updated objects.h and PeriperalNames.h against to the latest version of github. The problem sovled.

However, How CAN I make sure to export project with latest mbed libraries from online compiler? It seems exported one is not up to date.

Hi Kai,

The reason why it may not be exporting with latest mbed libraries is due to dependencies. Have you tried to manually update the revision of the libraries?


Andrea, team mbed

posted by Andrea Corrado 11 Nov 2016

1 Answer

3 years, 11 months ago.

I don't have an answer - just more questions.

I don't believe the answer provided in Nov 2016 regarding exporting of an older version of mbed libraries due to dependencies. I successfully compiled IHM031_EXAMPLEFOR3MOTORS only after updating all of the project files. I used the latest version of mbed-os. After successfully compiling it on-line with updated project files and mbed-os library, I exported it to vscode-gcc-arm. and got the same type of CAN.h errors.

I examined the mbed/.bld/bldrc file and found the reference to the old mbed version link: http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f Based on this link I assume that the export program packaged old mbed modules even though the on-line application used the latest mbed-os library. If that is the case there is probably a problem with the Export program.

Hopefully the Export program can be fixed if my conclusion is correct. But is there a way to load (manually) the current mbed-os files into the vscode folder until the export program can be fixed?