C++ Egg undefined reference to `typeinfo for EggObject'

Hi everyone!

I’m building a scientific data visualizer for 3D/2D data.
After testing different tools I choose Panda3D and I’m liking it a lot! (I think I’ll ask you guys a lot of questions … brace yourselves :smile: )

I did a few tests in python and now I’m going to test the C++ way, 'cause I’ll do the core of my program with C++.
Right now I’m trying the Egg library and I stumbled upon a linking error I don’t know how to deal with…

My setup:
Ubuntu 16.04
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

I compiled Panda3D from source, my last git commit (master) is:
commit eb367430f7d4aad7d01e5b9212534b066e5a21f6
Date: Thu Oct 8 11:17:36 2020 -0400

My issue is: when I add anything from Egg library, at linking time I have this error:

.rodata._ZTI14EggNamedObject[_ZTI14EggNamedObject]+0x18): -1 error: undefined reference to `typeinfo for EggObject’

Here attached there is a minimal example to test.
test.zip (1.8 KB)

The same code in python works (obviously)
Can someone help me?

Hiya, welcome!

Try compiling with -fno-rtti

I see. Thanks for your quick reply.

Using the flag as you suggested solved the issue for the dummy example.
Unfortunately I have to use our custom data that heavily rely on rtti, so by using that flag I get the opposite error:

error: cannot use typeid with -fno-rtti :sweat_smile:

So I see 3 options here:

  1. Tightly separate our data (that btw it is what have to be drawn) from egg library, maybe with a wrapper file.
  2. I saw that when compiling panda the -no-rtti is enabled. Another option would be to compile panda3D with rtti support. Is it doable in your opinion?
  3. Using something different from Egg library that allows me to use the rtti. Do you think it’ll make any difference or this rtti link issue will affect any panda library?

Thanks so much

Apparently compiling Panda3D with rtti (better, without disabling it) saved my day.
Linking is ok even when using my data and I can see something drawn inside the window.

I still have to learn how to draw something that actually make sense, but that’s another story :slight_smile:

So my question is “why rtti is disabled by default?” I saw a post saying it’ll same some memory on android devices, if I remember correctly. Is that the only reason? What’s the drawback?

btw: I’m not questioning, I’m a C++ lover and I’m eager to learn any bit of knowledge I can find.

We don’t use RTTI since we have a typing system that is a bit more efficient. There is therefore no need to pay for the additional overhead of enabling it.