Date
1 - 4 of 4
C++ support (Eclipse CDT4) - 'printk' could not be resolved #west
Hello!
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 Run: west build -b nrf52840_pca10056 C:/embedded/zephyrproject/zephyr/samples/hello_world -- -G"Eclipse CDT4 - Ninja" -D_ECLIPSE_VERSION=4.12 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) Thanks!
|
|
Bolivar, Marti
"leonardomt via Lists.Zephyrproject.Org"
<leonardomt=gmail.com@...> writes: Hello!Hi again! I copied these into samples/hello_world/prj.conf, but: 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: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
|
|
Hi and thanks for your prompt response!
I tried both toolchains, gnuarmemb and zephyr. I can successfully load a zephyr project *without cpp support* into Segger (as in the link) or Eclipse and compile, flash and debug just fine. Also, you are right in that everything works as expected when using the command line, no matter if the project is c or cpp. The issue only occurs when you use Eclipse to import a project that requires cpp support: Eclipse wont recognize some functions (such as printk) and some symbols, instead it will highlight them as if they were not declared anywhere. Just to make sure I understood correctly, you successfully built the project (the cpp version; main.c --> main.cpp), but did you import it into Eclipse and got no errors after indexing finished? I read that Eclipse has two separate tools for indexing and resolving symbols/function so I wonder if this error has anything to do with the configuration in Eclipse as opposed to the cmake generator. Another likely situation is that I am not setting things right... either way, help is appreciated! Thanks! Leo
|
|
Bolivar, Marti
"leonardomt via Lists.Zephyrproject.Org"
<leonardomt=gmail.com@...> writes: Hi and thanks for your prompt response!No, sorry, I just built it on the command line. I'm not an Eclipse user, sorry :(. It does sound like there's something wrong with the way either linking or symbol resolution is going on in Eclipse, though. Sorry I couldn't be more help. I thought you were seeing this issue on the command line. Marti
|
|