nomadicseadog / aeroquad

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

Error compiling AQ 2.1 (rev 505) with avr-gcc 4.5.1 #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using arduino 0021 with avr-gcc 4.5.1 and get error compiling AQ 2.1 (svn 
revision 505 from http://aeroquad.googlecode.com/svn/trunk/AeroQuad).

The error is:

AeroQuad.cpp.o: In function `global constructors keyed to fakeGyroRoll':
AeroQuad.cpp:1603: undefined reference to `vtable for Receiver'
AeroQuad.cpp:1603: undefined reference to `vtable for Receiver'
AeroQuad.cpp:1603: undefined reference to `vtable for Motors'
AeroQuad.cpp.o: In function `global constructors keyed to fakeGyroRoll':
Receiver.h:411: undefined reference to `vtable for Motors'
collect2: ld returned 1 exit status

Using avr-gcc 4.4.2 or build ok.

May be this FAQ from GCC can help: http://gcc.gnu.org/faq.html#vtables

Original issue reported on code.google.com by rgoros...@gmail.com on 28 Nov 2010 at 4:32

GoogleCodeExporter commented 9 years ago
It was related to issue 51 (now closed). Errors with vtable are fixed.

Now, with 2.1beta (rev 507) the error is:

In file included from AeroQuad.cpp:144:0:
FlightAngle.h: In member function 'void FlightAngle_DCM::Matrix_update()':
FlightAngle.h:371:1: error: unable to find a register to spill in class 
'POINTER_REGS'
FlightAngle.h:371:1: error: this is the insn:
(insn 205 204 207 7 FlightAngle.h:300 (set (reg:SF 118 [ D.7652 ])
        (mem/s:SF (post_inc:HI (reg:HI 14 r14 [orig:119 ivtmp.614 ] [119])) [2 this->DCM_Matrix S4 A8])) 13 {*movsf} (expr_list:REG_INC (reg:HI 14 r14 [orig:119 ivtmp.614 ] [119])
        (nil)))
FlightAngle.h:371: confused by earlier errors, bailing out

Original comment by rgoros...@gmail.com on 4 Dec 2010 at 1:57

GoogleCodeExporter commented 9 years ago
Same error in rev 558. Patch based on lokling git branch : 
https://github.com/lokling/AeroQuad/

Index: AeroQuad.h
===================================================================
--- AeroQuad.h  (revisión: 558)
+++ AeroQuad.h  (copia de trabajo)
@@ -383,4 +383,6 @@
     return free_memory;
 }

-
+// Error handling of virtual functions of  Receiver and Motors base classes  
+extern "C" void __cxa_pure_virtual() { Serial.print("ERROR: Virtual function 
called! "); }
+
Index: Receiver.h
===================================================================
--- Receiver.h  (revisión: 558)
+++ Receiver.h  (copia de trabajo)
@@ -50,8 +50,8 @@
   // ******************************************************************
   // The following function calls must be defined in any new subclasses
   // ******************************************************************
-  virtual void initialize(void);
-  virtual void read(void);
+  virtual void initialize(void) =0;
+  virtual void read(void) =0;

   // **************************************************************
   // The following functions are common between all Gyro subclasses
Index: Motors.h
===================================================================
--- Motors.h    (revisión: 558)
+++ Motors.h    (copia de trabajo)
@@ -64,9 +64,9 @@
   };

   // The following function calls must be defined in any new subclasses
-  virtual void initialize(void);
-  virtual void write (void);
-  virtual void commandAllMotors(int motorCommand);
+  virtual void initialize(void) = 0;
+  virtual void write (void) = 0;
+  virtual void commandAllMotors(int motorCommand) = 0;

   //Any number of optional methods can be configured as needed by the SubSystem to expose functionality externally
   void pulseMotors(byte quantity) {

Original comment by rgoros...@gmail.com on 11 Dec 2010 at 3:32

GoogleCodeExporter commented 9 years ago
Just wanted to double check if this is still an issue since I've seen 
additional work in the forums using AVR-GCC.  Reading through the last 
comments, I can fix this by adding "= 0" after declaration of virtual void 
functions?  We take this same approach with other classes, so wondering why 
it's an issue with Receiver.h.  Thanks@

Original comment by CaranchoEngineering@gmail.com on 20 Jan 2011 at 9:11

GoogleCodeExporter commented 9 years ago
I confirm this is still an issue with revision 569. Compiler output:

AeroQuad.cpp.o: In function `global constructors keyed to PID':
AeroQuad.cpp:1598: undefined reference to `vtable for Receiver'
AeroQuad.cpp:1598: undefined reference to `vtable for Receiver'
AeroQuad.cpp:1598: undefined reference to `vtable for Motors'
AeroQuad.cpp:1598: undefined reference to `vtable for Motors'
collect2: ld returned 1 exit status

Appears that this error is with AVR-GCC >= 4.5. I don't understand why only in 
Receiver.h and Motors.h. AFAIK The solution is add "=0" on declaration of 
virtual void functions in affected classes, and put in AeroQuad.h:
extern "C" void __cxa_pure_virtual() { Serial.print("ERROR: Virtual function 
called! "); }

this fix I was see in lokling's branch. The latest revision from lokling don't 
include the line "extern "C" ... " and when I try to compile the error is:

AeroQuad.cpp.o: In function `global constructors keyed to PID':
AeroQuad.cpp:1592: undefined reference to `__cxa_pure_virtual'
AeroQuad.cpp:1592: undefined reference to `__cxa_pure_virtual'
AeroQuad.cpp:1592: undefined reference to `__cxa_pure_virtual'
AeroQuad.cpp:1592: undefined reference to `__cxa_pure_virtual'
AeroQuad.cpp:1592: undefined reference to `__cxa_pure_virtual'
collect2: ld returned 1 exit status

I wish my poor english be suficient. Thanks in advance.

Original comment by rgoros...@gmail.com on 21 Jan 2011 at 3:24

GoogleCodeExporter commented 9 years ago
May be this thread help:

http://aeroquad.com/showthread.php?1672-AeroQuad-compilation-question&highlight=
vtable+Receiver

Original comment by rgoros...@gmail.com on 21 Jan 2011 at 3:30

GoogleCodeExporter commented 9 years ago
move feature to future release

Original comment by CaranchoEngineering@gmail.com on 14 Feb 2011 at 8:15

GoogleCodeExporter commented 9 years ago

Original comment by CaranchoEngineering@gmail.com on 25 Jun 2011 at 4:33