Go Down

Topic: Eclipse IDE C++ and Serial.begin()/print/whatever wants to destroy my life (Read 16681 times) previous topic - next topic


You are right about all issues mentioned. The template was only meant for Windows and as a result, you have to edit the paths to suit your installation. (The Joys of DOZE). I created the template to illustrate what is required to get the lot to work. Sort of a minimum requirement.
I compiled my set of libraries again and found no error. SD compiled as well.
The relative to work space paths help to get the stuff compiled. I used that option as I refer to the Core and Library object in the work space. As i recall I might have had some problems referring to outside objects.
One thing that I did, was to move the Arduino installation to the root of the drive. (c:\Arduino-022\..)

I use that exact work space for all my projects without any problems. I am sure that there is a small setup issue with your project. You should look at all the settings in the tool chain setup. Especially the includes and library directories. There are also some compiler switches and more. I don't remember all.
Rather people think you to be a fool than you open your mouth and confirm it.


Well I added the following to the top of my sketch:

  extern HardwareSerial Serial;

And now it builds just fine.

While this shouldn't be necessary, is there any downside to doing it as a quick n dirty fix?

"There is no problem so bad you can't make it worse" - retired astronaut Chris Hadfield


Given the code
Code: [Select]
#if defined(UBRRH) || defined(UBRR0H)
  extern HardwareSerial Serial;
#elif defined(USBCON)
  #include "usb_api.h"
#if defined(UBRR1H)
  extern HardwareSerial Serial1;
#if defined(UBRR2H)
  extern HardwareSerial Serial2;
#if defined(UBRR3H)
  extern HardwareSerial Serial3;

It is very likely it won't hurt.
However you are missing something in your eclipse environment which will cause issues later.
Look at your console window in eclipse after a build. My plugin (eclipse.baeyens.it) provided following output when compiling the file ddd.cpp
avr-g++ -I"C:\arduino-0023\arduino-0023\hardware\arduino\cores\arduino" -D__IN_ECLIPSE__=1 -DARDUINO=0023 -Wall -Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"ddd.d" -MT"ddd.d" -c -o "ddd.o" -x c++ "../ddd.cpp"
not all of the options are equally important. Following items may be missing or wrong in your case:
-Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL

I'm pretty sure you are missing the  -mmcu=XXXX option as this defines the __AVR_ATmegaXXXXX which on his turn defines UBRRH or UBRR0H or USBCON which defines Serial.

Best regards
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -


I'm having the same problem using Eclipse Indigo with Arduino Eclipse Extensions 1.2.1

I'm just compiling the following code:
Code: [Select]

#include "basic_test.h"
#include "HardwareSerial.h"

void setup() { Serial.begin(9600);}
void loop()   {}

I get the following errors when compiling:
Code: [Select]

Method 'begin' could not be solved
Symbol 'serial' could not be solved

Declaring "extern HardwareSerial Serial" does work, so I also thought that the problem should be related to the mmcu compiler parameter, but apparently not:

Code: [Select]
Invoking: AVR C++ Compiler
avr-g++ -I"/opt/arduino-1.0/hardware/arduino/cores/arduino" -I"/opt/arduino-1.0/hardware/arduino/variants/standard" -I"/home/ludovic/Arduino/basic_test" -D__IN_ECLIPSE__=1 -DARDUINO=100 -Wall -Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"basic_test.d" -MT"basic_test.d" -c -o "basic_test.o" -x c++ "../basic_test.cpp"
Finished building: ../basic_test.cpp

Any suggestions?


I am having the same issue... I can compile fine without using Serial but when I use it I get the message Symbol 'Serial' could not be resolved.

../Main.c:25: error: 'Serial' undeclared (first use in this function)
make: *** [Main.o] Error 1

I have a separate compiled AVR Cross Target Static Library library that my current AVR Cross Target Application is linked to.
HardwareSerial.h is even shown under the includes folder in project explorer.

I have both:
#include <C:\users\Sam\cpp_workspace\AVR_LIB\src\cores\arduino\HardwareSerial.h>
#include <C:\users\Sam\cpp_workspace\AVR_LIB\src\cores\arduino\HardwareSerial.h>
included at the top of my program.

I tried to extern HardwareSerial.h but got an error as well.

Any help would be much apprecieated!


@Samk and @ludovic
If you want some help I think it is important to state what you are using.
I mean are you using eclipse CDT purely?
Are you using avr-eclipse plugin?
Are you using the arduino eclipse plugin?
Without this basic info it is hard to give help.
I have never heard of "Arduino Eclipse Extensions 1.2.1". Where did you find this?

Best regards
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Go Up