Hi:) I would like to use virtual functions. I wrote simple test program: /*********************************************************************** ***/ #include "lpc2000.h" class A { public: void virtual fun1(){ GPIO_IOCLR |= (1<<21) ; } }; class B : public A{ public: void fun1(){ GPIO_IOCLR |= (1<<20); } void fun3(){ GPIO_IOCLR |= (1<<18); } }; //new object B sth ; int main(){ //main loop while(1){;} } /*********************************************************************** ***/ but compliler returns error: "C:\DOCUME~1\kuba\USTAWI~1\Temp/ccUDbaaa.o:(.rodata._ZTI1B[typeinfo for B]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' C:\DOCUME~1\kuba\USTAWI~1\Temp/ccUDbaaa.o:(.rodata._ZTI1A[typeinfo for A]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' collect2: ld returned 1 exit status make.exe: *** [main.elf] Error 1" What is going on or what is wrong ?
> What is going on or what is wrong ?
There is nothing intrinsically wrong with the code (although you should
consider including a virtual destructor in all virtual classes).
It is usually a good idea to post the entire compile log so we can see
how you are invoking the compiler/linker, and what if any other errors
occur.
Are you invoking the linker via the compiler, or calling the linker
separately? If so, are you using arm-elf-gcc or arm-elf-g++? You can use
gcc for C++ compilation, but if using gcc to launch the linker, it does
not automatically include the C++ library in the link (you need
-lstdc++). It does this automatically if you use g++.
Clifford
Clifford Slocombe wrote: >> What is going on or what is wrong ? > It is usually a good idea to post the entire compile log so we can see > how you are invoking the compiler/linker, and what if any other errors > occur. > Clifford My compiler log looks like this: -------- begin -------- arm-elf-gcc (GCC) 4.1.1 (WinARM) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Linking: main.elf arm-elf-gcc -mcpu=arm7tdmi -I. -DROM_RUN -O3 -Wall -Wcast-align -Wcast-qual -Wimplicit -lgcc -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=main.cpp -MD -MP -MF .dep/main.elf.d main.cpp --output main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc -lgcc -Tbuild/LPC2103-ROM.ld main.cpp:8: warning: 'class diody' has virtual functions but non-virtual destructor C:\DOCUME~1\kuba\USTAWI~1\Temp/ccw9baaa.o:(.rodata._ZTI5diody[typeinfo for diody]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info' collect2: ld returned 1 exit status make.exe: *** [main.elf] Error 1 What I can do for compiling without errors? I need virtual functions for happiness :)
Ok, I have changed options in makefile from: $(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS) to: $(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS) Now I have another problem, but solution is (probably) i two other posts: "C++ and WinARM" and "Linker problems". I will try to solve my problem with sugestions from this topics:) Thx
I was traying to use standard crt0.S file in my project, but compiler show result: -------- begin -------- arm-elf-gcc (GCC) 4.1.1 (WinARM) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Linking: main.elf arm-elf-g++ -mcpu=arm7tdmi -I. -g -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=build/crt0.o -MD -MP -MF .dep/main.elf.d build/crt0.o main.cpp --output main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc -lgcc -TLPC2103-ROM.ld c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:bu ild/crt0.o: file format not recognized; treating as linker script c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld.exe:bu ild/crt0.o:1: syntax error collect2: ld returned 1 exit status make.exe: *** [main.elf] Error 1 Why the file format is not recognized? Is it something wrong in makefile ? Maybe this file is incorrect? Why? :(
Jakub wrote: > Why the file format is not recognized? Is it something wrong in makefile > ? Maybe this file is incorrect? Why? :( A rebuild all may be useful so the log includes information about how crt0.s was built.
Do you see an error-message when compiling the example lpc2129_newlib_cpp from the example-collection that comes with WinARM? I do not use C++ in my "real" developments but this example should demonstrate virtual functions. Martin Thomas
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.