Eclipse compilation problem

Hi, I have some problems with eclipse compilation. I have followed the recommandation : I created the static lib and an application. The application is this example :

The source code is :

#include "WProgram.h"

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = " );
  Serial.print("\t output = ");

  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:

int main(void)


      for (;;)

      return 0;

When the source code of example is in a file main.cpp the errors are :

avr-gcc --cref -s -Os -o"AnalogInOutSerial.elf"  ./src/main.o   -lArduinoCore -lm -Wl,-Map,,--cref -L"C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release" -mmcu=atmega328
C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release\libArduinoCore.a(HardwareSerial.o):(.data+0x16): undefined reference to `__cxa_pure_virtual'
C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release\libArduinoCore.a(HardwareSerial.o):(.data+0x1c): undefined reference to `__cxa_pure_virtual'
C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release\libArduinoCore.a(HardwareSerial.o):(.data+0x1e): undefined reference to `__cxa_pure_virtual'
C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release\libArduinoCore.a(HardwareSerial.o):(.data+0x20): undefined reference to `__cxa_pure_virtual'
C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\Release\libArduinoCore.a(Print.o):(.data+0x6): undefined reference to `__cxa_pure_virtual'
make: *** [AnalogInOutSerial.elf] Error 1

When the source code of example is in a file main.c the errors are :

avr-gcc -I"C:\Users\Nassarane\Developpement\Arduino\ArduinoCore\src" -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328 -DF_CPU=16000000UL -MMD -MP -MF"src/main.d" -MT"src/main.d" -c -o"src/main.o" "../src/main.c"
../src/main.c:5: error: 'A0' undeclared here (not in a function)
../src/main.c: In function 'setup':
../src/main.c:14: error: 'Serial' undeclared (first use in this function)
../src/main.c:14: error: (Each undeclared identifier is reported only once
../src/main.c:14: error: for each function it appears in.)
../src/main.c: In function 'loop':
../src/main.c:21: warning: implicit declaration of function 'map'
../src/main.c:26: error: 'Serial' undeclared (first use in this function)
make: *** [src/main.o] Error 1

Where is the problem ?

Where is the problem ?

Perhaps you could search the forum for one or more of these terms: undefined reference to `__cxa_pure_virtual'

Personally, I'd skip the "to" search...

On the Arduino web site there is this :

You may need to add the following function when using the C++ headers:

extern "C" void __cxa_pure_virtual()
  for (;;);

Add this function to your main application file (main.c). It may work in a header file as well.

The contents of the function can be any error handling code; this function will be called whenever a pure virtual function is called.

But I understand no thing !!!

What don't you understand? A virtual function is one that a derived class [u]may[/u] override, with a different implementation. A pure virtual function is one that a derived class [u]must[/u] override.

If a derived class does not override a pure virtual function, the __cxa_pure_virtual() function will be called whenever an instance of the class tried to use a pure virtual function that it has failed to override.

Should that worry you? Not if you don't use derived classes, or are careful to override any pure virtual functions defined in the base class.

I have the solution !

I maned the file main.cpp (not main.c) and I add the function defined on the Arduino web site in the main.cpp file :

extern "C" void __cxa_pure_virtual()
  for (;;);

Thanks. Bye.