Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to get my C++ project to compile under ZephyrOS. It doesn't use many of the standard includes, but it uses <cmath> and my build system is such that it's not finding it. It uses GCC and not G++ and I was wondering if that might have something to do with it. I hope not, because the command line call is buried behind the West build system and the Cmakes are generated.

What sort of dead chicken do I have to wave to get this to work?

What I have tried:

Here's my command line

Shell
C:\Users\gazto\zephyr-sdk-0.16.1\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DCORE_CM7 -DHSE_VALUE=8000000 -DIO_NO_FS -DKERNEL -DLV_CONF_INCLUDE_SIMPLE=1 -DLV_CONF_PATH=../zephyr/lv_conf.h -DSTM32H723xx -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/Users/gazto/zephyrproject/zephyr/include -IC:/Users/gazto/zephyrproject/zephyr/applications/empty-project/build/zephyr/include/generated -IC:/Users/gazto/zephyrproject/zephyr/soc/arm/st_stm32/stm32h7 -IC:/Users/gazto/zephyrproject/zephyr/drivers -IC:/Users/gazto/zephyrproject/zephyr/soc/arm/st_stm32/common -IC:/Users/gazto/zephyrproject/htcw_bits/zephyr/../include -IC:/Users/gazto/zephyrproject/htcw_data/zephyr/../include -IC:/Users/gazto/zephyrproject/modules/lib/acpica/../../zephyr/include -IC:/Users/gazto/zephyrproject/modules/lib/acpica/.. -IC:/Users/gazto/zephyrproject/modules/lib/acpica/source/include -IC:/Users/gazto/zephyrproject/modules/lib/acpica/source/include/platform -IC:/Users/gazto/zephyrproject/modules/lib/acpica/source/compiler -IC:/Users/gazto/zephyrproject/modules/lib/acpica/generate/zephyr -IC:/Users/gazto/zephyrproject/modules/lib/acpica/source/tools/acpiexec -IC:/Users/gazto/zephyrproject/modules/lib/acpica/source/tools/acpidump -IC:/Users/gazto/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -IC:/Users/gazto/zephyrproject/modules/hal/stm32/stm32cube/stm32h7xx/soc -IC:/Users/gazto/zephyrproject/modules/hal/stm32/stm32cube/stm32h7xx/drivers/include -IC:/Users/gazto/zephyrproject/modules/hal/stm32/stm32cube/stm32h7xx/drivers/include/Legacy -IC:/Users/gazto/zephyrproject/modules/hal/stm32/stm32cube/common_ll/include -IC:/Users/gazto/zephyrproject/modules/lib/gui/lvgl/zephyr/../src -IC:/Users/gazto/zephyrproject/htcw_io/zephyr/../include -IC:/Users/gazto/zephyrproject/htcw_ml/zephyr/../include -IC:/Users/gazto/zephyrproject/htcw_gfx/zephyr/../include -isystem C:/Users/gazto/zephyrproject/zephyr/lib/libc/minimal/include -isystem c:/users/gazto/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem c:/users/gazto/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -fno-strict-aliasing -Os -fcheck-new -fno-exceptions -fno-rtti -imacros C:/Users/gazto/zephyrproject/zephyr/applications/empty-project/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m7 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/Users/gazto/zephyr-sdk-0.16.1/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/Users/gazto/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wno-unused-but-set-variable -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/gazto/zephyrproject/zephyr/applications/empty-project=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/gazto/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/gazto/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -nostdinc -MD -MT CMakeFiles/app.dir/src/main.cpp.obj -MF CMakeFiles\app.dir\src\main.cpp.obj.d -o CMakeFiles/app.dir/src/main.cpp.obj -c C:/Users/gazto/zephyrproject/zephyr/applications/empty-project/src/main.cpp
Posted
Updated 23-Jul-23 2:30am
Comments
Richard MacCutchan 23-Jul-23 3:47am    
As far as I know (from my experience in Linux and WSL) the gcc compiler does not handle C++ source. But I have no experience of ZephyrOS, which may have different rules. Can you not use the standard math.h functions?
honey the codewitch 23-Jul-23 3:50am    
For reasons known only to K&R NAN and INFINITY are not defined by C. Anywhere. Sometimes, some implementations of math.h provide it, but not on the systems I'm targeting.

Furthermore, while my graphics library does not rely on the STL it is in fact C++14 or C++17 (depending on the headers used). I know people use C++ with ZephyrOS, so maybe this is a zephyrOS question.

Thanks for your response. Basically it confirms for me that this is most likely a GCC vs G++ issue, and not a problem finding includes.
[no name] 23-Jul-23 4:46am    
Both infinity and nan were added to math.h way back in C99 so it sounds like you are compiling in C89 mode.
honey the codewitch 23-Jul-23 7:59am    
Ah thank you. I must have been looking at docs for the old standard. I had been at this stuff for so long at that point yesterday it doesn't surprise me.
[no name] 23-Jul-23 8:21am    
Yeah, gcc defaults to pure C89 unless you tell it to use a newer standard. You should probably add -std=c99 to your compiler flags.

The Microsoft C compiler defaults to a wierd C89/C99 hybrid.

1 solution

To fix, add the following to prj.cfg
CONFIG_CPP=y

Then it works.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900