ahmetsemihparlak / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Building using Makefile fails because undefined reference 'to__cxa_pure_virtual' #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Checkout rev 756 in
http://arduino.googlecode.com/svn/trunk/hardware/cores/arduino/
2. Modify 'Makefile' to suit your system.
3. Write a test pde. (Such as making the led blink)
4. run make

What is the expected output? What do you see instead?
I expect it to compile and get output such as this

   text    data     bss     dec     hex filename
      0    5170       0    5170    1432 applet/test.hex

Instead I get 

[...]
/usr/bin/avr-gcc -mmcu=atmega168 -I. -gstabs -DF_CPU=16000000
-I/home/seal/notes/arduino/src -Os -Wall -Wstrict-prototypes -std=gnu99  -o
applet/test.elf applet/test.cpp -L. applet/core.a -lm
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for
C/ObjC but not for C++
cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but
not for C++
applet/core.a(Print.o):(.data+0x6): undefined reference to `__cxa_pure_virtual'
make: *** [applet/test.elf] Error 1

If I declare it in the pde (as suggested by
http://note19.com/2009/07/02/arduino-development-with-command-line-tools/)
it works. The declaration looks like this.

extern "C" void __cxa_pure_virtual() {}  

What version of the Arduino software are you using?
rev 756, just the code in
http://arduino.googlecode.com/svn/trunk/hardware/cores/arduino/

On what operating system?
Arch Linux with:

* avr-libc 1.6.7-1
* binutils-avr 2.19.1-1
* gcc-avr 4.4.0-2

Please provide any additional information below.

[test]$ diff -u Makefile.old Makefile 
--- Makefile.old        2009-09-04 00:27:46.725895423 +0200
+++ Makefile    2009-09-04 00:28:47.642645214 +0200
@@ -35,8 +35,8 @@
 # $Id$

 TARGET = $(notdir $(CURDIR))
-INSTALL_DIR = ../../..
-PORT = /dev/tty.usb*
+INSTALL_DIR = /home/seal/notes/arduino/src
+PORT = /dev/ttyUSB0
 UPLOAD_RATE = 19200
 AVRDUDE_PROGRAMMER = stk500v1
 MCU = atmega168
@@ -45,8 +45,8 @@
 ############################################################################
 # Below here nothing should be changed...

-ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
-AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
+ARDUINO = $(INSTALL_DIR)
+AVR_TOOLS_PATH = /usr/bin
 SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
 $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
 $(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_shift.c \
@@ -149,6 +149,7 @@

 # Program the device.  
 upload: applet/$(TARGET).hex
+       stty -F $(PORT) hupcl
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)

Original issue reported on code.google.com by sebastia...@gmail.com on 3 Sep 2009 at 10:54

GoogleCodeExporter commented 9 years ago
I can reproduce this exact bug on Mac OS X snow leopard, with Arduino version 
17. 

Original comment by flix.t...@gmail.com on 7 Oct 2009 at 8:35

GoogleCodeExporter commented 9 years ago
I can also reproduce this with OSX Leopard (not Snow) with Arduino version 17.

Original comment by tuup...@gmail.com on 19 Oct 2009 at 8:20

GoogleCodeExporter commented 9 years ago
Error is due to a pure virtual function in Print.h. 

Attached is a diff which fixes the issue and updates the template Makefiles, as 
they 
appear to be out of date since version 0012.

Original comment by eoin.mcl...@gmail.com on 1 Feb 2010 at 10:22

Attachments:

GoogleCodeExporter commented 9 years ago
The Makefile is no longer supported, so I'm closing it.

I think there should be some way to build code that uses pure virtual functions 
(since they're a standard part of 
C++), but if it's a problem, please open another issue to propose the empty 
write() implementation in Print.

Original comment by dmel...@gmail.com on 1 Feb 2010 at 10:42

GoogleCodeExporter commented 9 years ago
Why isn't the makefile supported? Is there any other way of compiling without 
using
the full IDE?

Original comment by sebastia...@gmail.com on 2 Feb 2010 at 7:04

GoogleCodeExporter commented 9 years ago
The decision has been made.  Better hang onto those changes.  The Makefile 
never worked anyway, and a stub 
would just break local changes. You can still build with a Makefile, but you 
have to cook up your own.

Original comment by clvrm...@gmail.com on 2 Feb 2010 at 2:07

GoogleCodeExporter commented 9 years ago
Note that the Arduino IDE manages to avoid the linker error about 
__cxa_pure_virtual when building some programs because it compiles with the 
options "-ffunction-sections -fdata-sections" and links with 
"-Wl,--gc-sections", which drops some references to unused symbols.

Original comment by mseaborn@chromium.org on 20 Feb 2012 at 11:55