c++gccg++gcc-plugins

Build gcc plugin using other files


You probably don't need to know a lot about gcc plugin to understand this problem

Hi, I am trying to create a gcc plugin that uses other files as classTree.cpp and field.cpp, I never had a problem building the plugin when I had ne referene to other classes : I was using this command by the way :

    g++ -shared -I`g++ -print-file-name=plugin`/include 
           -I`g++ -print-file-name=plugin`/include/c-family -fPIC -fno-rtti -O2  
            order_checker.cpp -o plugin.so

and use it with this one :

g++  -fplugin=./plugin.so tinytest.cpp -o toto

All as showed in the gcc plugins Doc, they also say that when I am using other files, I just need to add the name of my files like this :

    g++ -shared -I`g++ -print-file-name=plugin`/include 
        -I`g++ -print-file-name=plugin`/include/c-family -fPIC -fno-rtti -O2        
         order_checker.cpp classTree.cpp field.cpp -o plugin.so

When I use this, plugin.so is created, but when I try to run it like before, I get this error :

cc1plus: error: cannot load plugin ./plugin.so
./plugin.so: undefined symbol: _ZTV5field

What does the error mean ? especially the symbol: _ZTV5field ?


Solution

  • _ZTV5field is1 the virtual function table for class field, as c++filt can tell you:

    $ echo _ZTV5field | c++filt 
    vtable for field
    

    That this symbol is undefined means that the compiler could not generate this table, which in all likelyhood means that class field has a virtual member function that you have forgotten to implement.

    1 in the Itanium ABI that gcc has been using on non-Windows platforms since version 3.2.