This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GNU Linaro C++ virtual functions problem

Hi all,

I am developing an C++ application in the CCS (v6.01) for the  AM437x processor using Sys/BIOS (6.41.4.54) and Linaro GCC compiler (version 4.9.3).
The problem is that the Linaro can´t compile the code with virtual functions, I allways get this error

"undefined reference to `vtable for __cxxabiv1::__si_class_type_info'"

Here´s the example code

// AbstractExampleClass.h

class AbstractExampleClass
{
public:
    virtual int oveverrideFunction(int x) = 0;
};

// Test.h

class Test : public AbstractExampleClass
{
public:
    int oveverrideFunction(int x);
};

// Test.cpp - dummy implementation

int Test::oveverrideFunction(int x)
{
    return x;
}

After removing virtual keyword everything compiles normally.

This code can be normally compiled with the TI´s compiler, but the problem is that TI´s compiler doesn´t support SYS/BIOS on AM437x core.

I would like to know if it is possible to compile virtual functions with the Linaro GCC compiler at all. And if so which compiler properties have to be set.


Thank you,

Slaven

  • I am unable to reproduce this failure.  Please submit a more complete test case.  In particular, show exactly how the compiler is invoked.

    Thanks and regards,

    -George

  • Hi George,

    Thank you very much for a quick responce. I´ve attached a small demonstration project.

    The compiler is invoked like this:

    "D:/ti/ccsv6/tools/compiler/4.9 2015q1/bin/arm-none-eabi-gcc.exe" -mfloat-abi=hard -Dam4379 -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,"dummySysBios.map" -nostartfiles -static -Wl,--gc-sections -L"D:/ti/bios_6_41_04_54/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu" -Wl,--defsym,STACKSIZE=0x18000 -Wl,--defsym,HEAPSIZE=0x400 -o"dummySysBios.out" "./Test.o" "./main.o" -Wl,-T"./configPkg/linker.cmd"  -Wl,--start-group -l"c" -l"gcc" -l"m" -l"nosys" -Wl,--end-group

    And error list is

    /Test.o:(.rodata+0xc): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
    ./Test.o:(.rodata._ZTI20AbstractExampleClass[_ZTI20AbstractExampleClass]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
    ./main.o:(.rodata._ZTV20AbstractExampleClass[_ZTV20AbstractExampleClass]+0x8): undefined reference to `__cxa_pure_virtual'
    collect2.exe: error: ld returned 1 exit status
    gmake: *** [dummySysBios.out] Error 1
    gmake: Target `all' not remade because of errors.

    If you need any other information please let me know.

    Best Regards,

    Slaven

     

    dummySysBios.rar

  • The class_type_info entities are defined in the C++ runtime support library.  So, you need to add 

    -l"stdc++"

    to the list of libraries specified to the linker.

    Thanks and regards,

    -George

  • Hi George,


    It looks like this solves the problem.


    Thank you.