Re: C++ support (Eclipse CDT4) - 'printk' could not be resolved #west


Bolivar, Marti
 

"leonardomt via Lists.Zephyrproject.Org"
<leonardomt=gmail.com@lists.zephyrproject.org> writes:

Hello!
Hi again!


I am failing to create a Zephyr project for Eclipse with C++ support.
Is there a working example or guide I can use as reference to set this up?
My end goal is to use Zephyr + nRF SDK in C++ with debugging in any IDE, preferably SEGGER or Eclipse.

After importing project "hello_world", Eclipse underlines function "printk" in red:
==> Function 'printk' could not be resolved <==
==> Symbol 'CONFIG_BOARD' could not be resolved <==

Here's the steps I follow to setup the project:
Toolchain:
Zephyr 2.0.0
west v0.6.0
ninja 1.9.0
cmake 3.15.2
Eclipse 4.12 + GNU MCU 4.5.1

Edit prj.conf and .config:
CONFIG_PRINTK=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_NEWLIB_LIBC=y
CONFIG_LIB_CPLUSPLUS=y
I copied these into samples/hello_world/prj.conf, but:


Run:
west build -b nrf52840_pca10056
C:/embedded/zephyrproject/zephyr/samples/hello_world -- -G"Eclipse
CDT4 - Ninja" -D_ECLIPSE_VERSION=4.12
I can't reproduce this on my Arch Linux machine with
ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb, toolchain version
gcc-arm-none-eabi-7-2018-q2-update.

The build finishes successfully for me, and works when I flash it to my
board.

What toolchain are you using? Can you try with gnuarmemb?

https://docs.zephyrproject.org/latest/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded

One warning:
<...>
[18/98] Building CXX object CMakeFiles/app.dir/src/main.cpp.obj
cc1plus.exe: warning: command line option '-Wno-pointer-sign' is valid for C/ObjC but not for C++

Import project into Eclipse
Error in main.cpp:
Function 'printk' could not be resolved

Also tried:
set (CMAKE_CXX_STANDARD 11) in CMakeLists.txt
Manually add "__cplusplus=201402L" as a symbol in Eclipse (cmake does not generate such symbol in .cproject)
Force boilerplate.cmake to call eclipse_cdt4_generator_amendment with
work mode = 2 (.cproject with __cplusplus)
BTW, since you mentioned Segger and you're using nRF:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_programming.html#building-with-ses

Best,
Marti


Thanks!

Join users@lists.zephyrproject.org to automatically receive all group messages.