[ECOS] eCos virtual functions

Ivan Kostov ikostov@ira.uka.de
Sun Jul 15 14:05:00 GMT 2007


Hi everybody,
for our  project  we decided to use C++ code with virtual functions,
but when I try to compile code like this:

class Abstract {
protected:
    int a;
public:
    virtual void seta(int);
    virtual int geta();
    virtual ~Abstract();
};


class Derived : public Abstract {
public:
    virtual void seta(int);
    virtual int geta();
};

void Derived::seta(int para)
{
    a=para;
}

int Derived::geta()
{
    return a;
}

I get an error message from make:make

g++ -c -g -o main.o -I/home/kostov/syn-ecos/ecos_install//include -Wall
-Wpointer-arith -Winline -Wundef -g -O2 -ffunction-sections
-fdata-sections -fno-exceptions main.cpp
g++ -nostartfiles -L/home/kostov/syn-ecos/ecos_install//lib -Ttarget.ld
-g -nostdlib -Wl,--gc-sections -Wl,-static -g -o main main.o errors.o
`__gxx_personality_v0' referenced in section
`.gnu.linkonce.d.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]'
of /usr/lib/gcc/i586-suse-linux/4.0.2/../../../libsupc++.a(tinfo.o):
defined in discarded section `.text.__gxx_personality_v0' of
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libsupc++.a(eh_personality.o)collect2:
ld returned 1 exit status
make: *** [main] Error 1

I'm using synthetic target. I just changed the target.ld to:

MEMORY
{
    rom : ORIGIN = 0x00000000, LENGTH = 0x800000
    ram : ORIGIN = 0x02000000, LENGTH = 0x800000
}

When I try to compile this without any special options:

g++ -o main -I/home/kostov/syn-ecos/ecos_install/include
-L/home/kostov/syn-ecos/ecos_install/lib -Ttarget.ld -nostdlib main.cpp

I get the error message:

/tmp/ccaS3wuZ.o:(.gnu.linkonce.r._ZTI7Derived[typeinfo for
Derived]+0x8): undefined reference to `typeinfo for Abstract'
/tmp/ccaS3wuZ.o: In function `Derived::~Derived()':
main.cpp:(.gnu.linkonce.t._ZN7DerivedD1Ev[Derived::~Derived()]+0x18):
undefined reference to `Abstract::~Abstract()'
/tmp/ccaS3wuZ.o: In function `Derived::~Derived()':
main.cpp:(.gnu.linkonce.t._ZN7DerivedD0Ev[Derived::~Derived()]+0x18):
undefined reference to `Abstract::~Abstract()'
collect2: ld returned 1 exit status

I'm sorry if this is already discussed in the mailing list, but I am new
to eCos (yep, I have googled about "ecos virtual functions" anyway ;) ).
Thanks in advice to everybody.

Cheers,
Ivan Kostov


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list