USBDevice, USBSerial, etc not found

Hello, trying to #include “USBSerial.h” or “USBHID.h” or any USB library results in

fatal error: USBSerial.h: No such file or directory
    3 | #include "USBSerial.h"
      |          ^~~~~~~~~~~~~
compilation terminated.

I’m building with mbed-tools compile -m LPC1768 -t GCC_ARM and my mbed-tools version is 7.59.0. My only other inclusions are “mbed.h” and and my mbed_app.json looks like:

        "config": {
        "usb_speed": {
            "help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
            "value": "USE_USB_OTG_FS"
        "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-buffered-serial": 1,
            "target.printf_lib": "minimal-printf",
            "platform.minimal-printf-enable-floating-point": true,
            "platform.minimal-printf-set-floating-point-max-decimals": 2,
            "target.device_has_add": ["USBDEVICE"]

I have tried adding "requires": ["drivers-usb"] but this results in a ton of redefinition errors. I just want to set up my LPC1768 to send data over usb, and would like to use the USBHID or USBSerial library to do that. Thanks!


I do not know which version of MbedOS do you use but LPC1768 has this setting already in default

So it is not necessary to add it.

BR, Jan


You probably need to add “mbed-usb” in the CMakeLists.txt. See detail here: