Eclipse cannot resolve symbol Serial

Status
Not open for further replies.

marv

Member
Hi all,

I would like to use Eclipse to write code for Teensy 3.2 but use make as external builder. I have a working Makefile, and added include paths for the teensy core library and all the Arduino libraries to the eclipse project's configuration, so that the indexer can find all the symbols. It works for the libraries and everything, but Eclipse somehow keeps complaining that it does not find the symbol "Serial" and all its methods like begin(), println()... I attached the Makefile and a minimal program.

Do you have any clue why Eclipse does not find Serial?

Best Regards,
Marv

View attachment main.cpp View attachment Makefile.txt
 
Do you have any clue why Eclipse does not find Serial?

All my Eclipse programs
start with
Code:
#include "kinetis.h"
#include "core_pins.h"
#include "usb_serial.h"
I guess
Code:
#include "arduino.h"
would be sufficient
 
Hi WMXZ,

thanks for your answer.

Unfortunately the problem still persists; also after rebuilding or refreshing the index. I think that WProgram.h also includes all these headers already. It seems that some parts are only included conditionally (if __cplusplus is defined). Did you add additional include paths apart from the teensy3 core directory? I only have this problem with the eclipse indexer but not when building with the Makefile.
 
AFAICS WProgram.h does not include "kinetis.h" the basic Teensy include file.

Anyhow,
you are using "main()"
However, main is already used in "mk20dx128.c" the basic core routine for T3.x (ignore the name, it is for all T3.x and not only for T3.1)
so you should have C-type setup() and loop() functions
I'm not sure how two competing main() entries are handled.

Otherwise, as Paul noted are you using Jantje's plug-in or plain Eclipse, which version?
(I use plain Eclipse Cpp Neon.3, without Jantje's plug-in)

Because you asked, all code that is being called must be added to the workspace (as link or as copy). This seems obvious. Libraries for the linker must be given.

can you get a 'empty' setup()-loop() program be compiled? What is the size?
 
Are you using Jantje's plugin for Eclipse?
No, I am using plain Eclipse (Oxygen December 2017) with CDT.

However, main is already used in "mk20dx128.c" the basic core routine for T3.x
My understanding is that mk20dx128.c only contains the function prototype for main() and then calls it after running the teensy startup code. The teensy3 core library contains a main.cpp file which actually defines the main function. By default this main function then delegates to the setup() and loop() functions defined by the programmer. I deleted that file, hence my definition of the main() function is called by mk20dx128.c. The setup() and loop() functions are not needed anymore.

Because you asked, all code that is being called must be added to the workspace (as link or as copy). This seems obvious. Libraries for the linker must be given.
I got everything working now as I wanted. Code does not necessarily need to be added to the workspace. What is important to stress here is that I am not using the "Managed build" feature by eclipse, but edit and run the Make targets myself. Previously I already added the teensy3 core library path and all the Arduino Library paths to 'Project properties->C/C++ General->Paths and Symbols->Includes'. What was missing to make it work were some symbols. When I added F_CPU and USB_SERIAL to the symbols tab it worked. The name Serial could not be resolved because there are some conditional includes. I now added all the options which were set in the Makefile. Maybe this can also be achieved by Auto discovery (Build output parser).

can you get a 'empty' setup()-loop() program be compiled? What is the size?
Thanks to a hint of Paul, I added archiving of the core library to the Makefile. That's what the Arduino IDE build system also does. Somehow that saves some little extra space compared to directly linking the object files. (See attached Makefile) The resulting hex file for this minimal program is 3430 bytes.

For anyone interested in using this Makefile; you can add the basename of Arduino library paths to get them linked too.

View attachment Makefile.txt
 
Last edited:
Status
Not open for further replies.
Back
Top