Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Eclipse cannot resolve symbol Serial

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    5

    Eclipse cannot resolve symbol Serial

    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

    main.cpp Makefile.txt

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,542
    Quote Originally Posted by marv View Post
    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

  3. #3
    Junior Member
    Join Date
    Dec 2017
    Posts
    5
    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.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    16,238
    Are you using Jantje's plugin for Eclipse?

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,542
    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?

  6. #6
    Junior Member
    Join Date
    Dec 2017
    Posts
    5
    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.

    Makefile.txt
    Last edited by marv; 12-28-2017 at 04:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •