Go Down

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

smerten

Hi, i am just starting a small project conserning LEDs and cubes. http://dl.dropbox.com/u/419037/purpleorange.png

But nevermind that, I am having troubles using Serial.print() in a C++ enviornment in Eclipse. I thought it would work more or less the same as the other functions, I am having no trouble with digitalRead/Write etc.

ive built the libraries myself, and followed the eclipse guide to get myself up and running with AVR.
Here is a successful build without any use of Serial.*
http://pastebin.com/kT0rnDDz

I dont think the fact that im building as debug should be any issue, ive tried building as release with a different guide.

http://dl.dropbox.com/u/419037/screen1.png

With the Serial.begin()


Description   Resource   Path   Location   Type
make: *** [BlinkExample.elf] Error 1   BlinkExample          C/C++ Problem
Method 'begin' could not be resolved   main.cpp   /BlinkExample   line 38   Semantic Error
Symbol 'Serial' could not be resolved   main.cpp   /BlinkExample   line 38   Semantic Error

Probably something silly, any advice would be appreciated.

Marius

I assume that you compiled the core functions into a library without the main loop stuff and that you compiled the core library with the same clock frequency settings as your current project. You also compiled it for the same chip.
Rather people think you to be a fool than you open your mouth and confirm it.


sixeyes

Sounds like you've not defined the global object Serial. In the Arduino environment this is defined in HardwareSerial.h / HardwareSerial.cpp

Have you got this file in your library?

If so are you including HardwareSerial.h or WProgram.h?

Remember that eclipse isn't like the Arduino IDE. It doesn't do anything for you. You HAVE to include all the headers yourself, declare all functions and include all libraries for the linker.

Iain

Marius

Have a look at this post, I added a zip file that contains a template and all the settings that you need to get going.

http://arduino.cc/forum/index.php/topic,66169.0.html

Marius
Rather people think you to be a fool than you open your mouth and confirm it.

smerten

Tried having a look at those files. Only path that needed obvious changing was the c:\users\marius ones.

But still, getting linking errors.

What AVR are you using?

sixeyes

Quote

But still, getting linking errors.


Has your error message changed?
In your original post you are getting a compilation error.

Iain

Marius

I am using the 328p at 16mHz.

The main() must be in your application and not in the core library.
Rather people think you to be a fool than you open your mouth and confirm it.

hatepod

I have exactly the same problem. I can use eclipse to compile->build->upload the "blink" example.
However as soon as I try use "Serial", the compiler gives the following error:

Code: [Select]
Symbol 'Serial' could not be resolved main.cpp line 10 Semantic Error

I use the library that arduino ide generates (copied from /tmp). I also included every .h file that I found under <Arduino>/ directory to the eclipse project. But still I get the same error.

Does anyone know the reason for this? How may I solve this problem?


sixeyes

You need to include HardwareSerial.h:

Quote
#include "HardwareSerial.h"


You may need to include a path in front of the file if it's in a different location. For example in my setup I need to use

Quote
#include "Arduino/HardwareSerial.h"


as I've built the Arduino library in an Arduino folder in my workspace.

Iain

B2

Has anyone resolved this problem as I am experiencing the same thing.

B2

B2

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

  extern HardwareSerial Serial;

And now it builds just fine.

B2

kiwidude

No special options are required, but some settings in eclipse and the general project setup are critical. Declaring HardwareSerial extern or some such thing is definitely not required, you must have a broken setup.

Look here for a detailed explanation:
http://www.arduino.cc/playground/Code/Eclipse

Be aware that there are quite a few bugs in the eclipse AVR plugin, and some in the eclipse CDT plugin which the AVR one is based on.

Marius

I agree with KiwiDude, you need not make special declarations. Have a look at this template workspace for Adruino that I created.

https://github.com/mariusl/Eclipse-for-AVR

Place all three projects in the same work space. Compile each of the projects starting with the ArduinoCore and then the AdruinoLibraries and lastly the Template.

I use this work space for all my projects and never have any issues. I import libraries from the arduino/libraries directory when I need a new one. Recompile and go.
Rather people think you to be a fool than you open your mouth and confirm it.

kiwidude

Marius, your template archive is an interesting idea but falls flat in several ways. Your path configuration works only on doze, and only if someone installs the same way as you. Use workspace-relative paths. Your example includes Wprogram.h which barfs on anything but the one OS around that is case-insensitive. The SD library in there compiled with errors. I didn't look further, but eclipse thought boolean was undefined.

Go Up