Code compiling on MacOS, but throwing errors on Linux Ubuntu 20.04

I downloaded PlatformIO for VSCode on both my Mac and on Ubuntu, but I’m finding that the code is not compiling on Ubuntu for some reason, but compiles fine on my Mac.
I’m running generated code from STM32CubeMX, and I’m just doing a simple project transmitting over usb. It looks like on Ubuntu, PlatformIO links in other libraries from .platformio/packages, but not on Mac. Should I be unlinking these, and if so, how do I do that?

src/usbd_conf.c:730:20: error: conflicting types for 'USBD_LL_Transmit'
 USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
                    ^~~~~~~~~~~~~~~~
In file included from src/usbd_conf.c:26:0:
/home/simonxu/.platformio/packages/framework-stm32cubel4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h:126:20: note: previous declaration of 'USBD_LL_Transmit' was here
 USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
                    ^~~~~~~~~~~~~~~~
src/usbd_conf.c:765:20: error: conflicting types for 'USBD_LL_PrepareReceive'
 USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
                    ^~~~~~~~~~~~~~~~~~~~~~
In file included from src/usbd_conf.c:26:0:
/home/simonxu/.platformio/packages/framework-stm32cubel4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h:129:20: note: previous declaration of 'USBD_LL_PrepareReceive' was here
 USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr,

Are you sure both OS’s have the same version of everything? You can e.g. open a CLI and execute pio upgrade and pio platform update so update the core and the platforms.

After that, they should behave the same.

Now if that behavior is an error, we need to see the full project.

Note that STM32Cube support / building was majorly redone in a recent platform-ststm32 release version. A STM32Cube + USB example project can be found at platform-ststm32/examples/stm32cube-hal-usb-device-dfu at develop · platformio/platform-ststm32 · GitHub.

Thanks, in both cases i have Core 5.1.0 and Home 3.3.3, so that doesn’t seem to be the issue.

I’m not using a Nucleo board, but actually a disco_l475vg-iot01a. What seems to be difference on Ubuntu vs mac is that on Ubuntu, it links in drivers from ~.platformio/packages/framework-stm32cubel4/Drivers. This folder doesn’t exist on the build in Mac, I have the drivers put in the “lib” folder.

After I deleted the Driver libraries from my file tree, it is able to compile after fixing some compile errors.

However, now I am running into this issue when uploading:
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
in procedure ‘program’
** OpenOCD init failed **
shutdown command invoked

It seems like you have some experience with how to handle this in Linux? Thanks so much in advance.

This per-sé seems weird – the STM32CubeL4 package is the same for all OSes, since it just contains files. It can also be downloaded and inspected at Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog.

If the files / folder structure differs, then it’s more likely that the download was corrupted on the Mac. Try deleting the /Users/<user>/.platformio/packages/framework-stm32cubel4 and /Users/<user>/.platformio/.cache folders and rebuild the project to get a fresh download.

Probably no udev rules installed? If it works with sudo pio run -t upload on the CLI, that’s definitely the cause.