Question

I use C++/Qt for my project and I am facing this strange issue.

My application runs fine on any native Linux machine and Windows. The problem appears when I use a remote Linux machine to execute my program and use a X Windows server (I use Xming) to view/use it.The debugger points to a line where the dynamic_cast fails to get the object pointer(the cast returns a nice NULL) instead of the actual object I wanted.

I suspect some configuration issue which I must be missing to enable these runtime checks.

Anyone has faced such issues, any pointers towards a solution would be welcome.

Was it helpful?

Solution 2

Ok, After a lot of trials this was the solution.

I needed to export the interface classes explicitly, using attribute((visibility("default"))) And to make sure there is an entry in the vtable, define and empty virtual destructor for this.

It seems on some linux machines, if I don't export It does not recognize the RTTI, and returns a NULL.

OTHER TIPS

How have you linked? We had a similar problem with our Java plug-ins. If the dynamic_cast is in a different DLL than the DLL where the object was constructed, RTLD_GLOBAL must be set in the call to dlopen when the DLLs are loaded. If the DLLs are loaded implicitly, whether it is set will depend on how it was set for the DLL triggering the load (which means that you may have no control over it). In the end, we had to ensure that no .so were loaded implicitly (by having Java load a special loader DLL, which loaded everything explicitly, in the dependency order).

Note that this may not be your problem; I'm just guessing, since I don't have enough information. But we had exactly the same symptoms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top