Linker cannot find vftable for class

Started by
4 comments, last by aclysma 16 years, 2 months ago
I am trying to compile the LuaScriptModule class into my current project. LuaScriptModule comes with CEGUI but is optional and therefore not compiled in with the CEGUI binaries. I am using Ogre 1.4.5 which includes CEGUI (but again not the LuaScriptModule). I have Lua 5.1 in my project. Everything is compiling ok, but when I try to link I get one single error: CEGUILua.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) const CEGUI::LuaScriptModule::`vftable'" (__imp_??_7LuaScriptModule@CEGUI@@6B@) This error comes up whether I try to instantiate the class or not. The CEGUI binaries included with ogre require me to both link a .lib file and have a DLL present. To my understanding, vftable indicates the virtual function table, which is something that should be getting generated by my compiler. I am using visual studio 2005 with options: Multithreaded DLL, with RTTI and exceptions on. Does anyone have any suggestions? I am sure there is some information that I'm not including that is necessary to solve this, so please ask and I'll respond as quickly as possible.
Advertisement
Have you made modifications to CEGUI as it was not compatible with lua 5.1(unless it has been changed lately). See this post for more info.
To my understanding, the only changes that have to be done would be within the script module which I'm including directly in my own code. I have not made any changes but I believe they would show up at runtime, not at compile time.

I found this patch which looks very similar to what you just linked.
http://bugs.gentoo.org/attachment.cgi?id=118584

I was hoping to not have to recompile ogre and cegui (and subsequently lots of dependencies). Seeing that the LuaScriptModule is separate from the base CEGUI build (and actually links it in if you look at the build scripts within CEGUI) I don't think this should cause a problem.. though apparently it does.

I think if I could figure out why the vftable isn't available I'll be fine*. I'd like to point out that the constructor and all other functions of the LuaScriptModule are there because if in the code I attempt to instantiate it, I see no linker errors (while I *do* see linker errors if I remove the cpp files).

Thanks

(*EDIT: by fine, I mean it will build and I'll be able to fix the errors that show up at runtime within lua due to lua libraries not being available)
What does it mean that the "virtual table" is an unresolved external?
No luck. The LuaScriptModule declares and implements every method in ScriptModule, its one and only base class very cleanly in the standard .h/.cpp per class form. ScriptModule does not extend anything.

I think I'll try to write my own extension of ScriptModule with just empty function definitions and see if I can get that to link.. and if not then I'll at least begin to narrow down to the problem.

Still open to suggestions
I stubbed out my own ScriptModule with empty implementations and got far enough in the linking process to believe that it wasn't the fact that I was extending an interface defined in the DLL.

Then I copied the LuaScriptModule's class and removed everything and made it stub out and that worked fine too. I narrowed it down to CEGUILUA_API being in front of the functions. This is defined as __declspec(dllexport).

So I don't really know what __declspec(dllexport) but I wonder if that made the compiler think the DLL had a vtable that needed to get used. In any case, it is working now and when I get to a stopping point I'll go read more on __declspec(dllexport) and DLLs in general. I think if I had known more about these two things I wouldn't have gotten hung up.

I am getting runtime errors as was expected. I'll get it working and then confirm what worked.

Thanks for the help!

(EDIT: the instructions at dmail's link worked great and everything seems to be working fine. Thanks again)

[Edited by - aclysma on January 31, 2008 1:41:18 AM]

This topic is closed to new replies.

Advertisement