Compile issues on mac

Hi, I tried to compile the firmware (master branch) on my macbook pro and I’m facing an issue, I’m getting

arm-none-eabi-g++: error: unrecognized command line option '-std=c++14'

if I change to -std=c++1y it passes through but I get another error

arm-none-eabi-g++ -std=c++1y -c MotorControl/protocol.cpp -DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=1 -DHW_VERSION_VOLTAGE=24 -DUSB_PROTOCOL_NATIVE -DUART_PROTOCOL_LEGACY -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F405xx -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -Og -ffast-math -fstack-usage -IDrivers/DRV8301 -IMotorControl -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/include -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -IBoard/v3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -IBoard/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -IBoard/v3/Drivers/STM32F4xx_HAL_Driver/Inc -IBoard/v3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -IBoard/v3/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IBoard/v3/Drivers/CMSIS/Include -IBoard/v3/Inc -IMotorControl -IDrivers/DRV8301 -o build/MotorControl_protocol.cpp.o MotorControl/protocol.cpp: In member function 'void Endpoint::write_json(size_t, bool*, StreamSink*) const': MotorControl/protocol.cpp:69:50: error: 'snprintf' was not declared in this scope snprintf(id_buf, sizeof(id_buf), "%u", id); // TODO: get rid of printf

I have the latest gcc installed using brew

arm-none-eabi-g++ --version arm-none-eabi-g++ (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I suspect has to do with the specified C++ dialect, did anyone see this?

I have had no problems on mac, and just compiled in the Firmware directory using make.

My gcc version I believe is default XCode:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

thanks @moorage
don’t you need gnu arm to compile?

I don’t believe that you do.

Hi @moorage
I think there’s a misunderstanding here, what i know is that xcode gcc generates a binary for the intel CPU not the arm code inside the ST chip. After some experiments it seems that GNU ARM 7 (the latest version online) does spit out the std=c++1y error, after install 4.9.3 the error went away

I literally ran make clean && make, and then make flash with the external programmer plugged into my mac and the odrive, and it’s been working, without any special version of GCC. I haven’t looked to see how the Makefile targets arm for the odrive.

I think @moorage is confused here, you do indeed need to check the version of arm-none-eabi-gcc, not gcc.

@sherif I don’t know what is going on with your original error, -std=c++14 should be valid. Maybe there is a bug in this specific version of arm-none-eabi-gcc? I haven’t seen the issue before so I’m just guessing. Are you able to try to install an older version with brew? (I’m using gcc/g++ interchangeably here)

@madcowswe from what I’ve tried arm gcc 4.9.3 works fine, 4.8.2 doesn’t, and version 7 (latest) doesn’t

Ah ok. Here’s my version that is working with make and make flash for me

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.