Game Development Community

Exporting to .dll - very strange error

by Shyam "Doggan" Guthikonda · in Torque Game Engine · 06/16/2006 (8:14 am) · 1 replies

For this application, we are compiling our networking component into a .dll. We are using TNL as the network framework. Has anyone successfully derived classes from TNL and compiled this successfully into a .dll?

I am getting the strangest COMPILE error when I try to subclass TNL::NetInterface, and I am dllexporting the subclass.

For example:

class __declspec(dllexport) myNetInterfaceWrapper : public TNL::NetInterface
{
public:
   myNetInterfaceWrapper(const TNL::Address &ad)
      : TNL::NetInterface(ad)
   {}
};

produces this compile error:

c:\Documents and Settings\shyam\Desktop\New Folder (2)\testApp\testApp.cpp(7) : warning C4275: non dll-interface class 'TNL::NetInterface' used as base for dll-interface class 'myNetInterfaceWrapper'
        c:\LIB_TNL\tnl\tnlNetInterface.h(143) : see declaration of 'TNL::NetInterface'
        c:\Documents and Settings\shyam\Desktop\New Folder (2)\testApp\testApp.cpp(6) : see declaration of 'myNetInterfaceWrapper'
c:\LIB_TNL\tnl\tnlNetBase.h(514) : error C2664: 'TNL::RefObjectRef::RefObjectRef(TNL::Object *)' : cannot convert parameter 1 from 'TNL::AsymmetricKey *' to 'TNL::Object *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
        c:\LIB_TNL\tnl\tnlNetBase.h(514) : while compiling class-template member function 'TNL::RefPtr<T>::RefPtr(const TNL::RefPtr<T> &)'
        with
        [
            T=TNL::AsymmetricKey
        ]
        c:\LIB_TNL\tnl\tnlNetConnection.h(101) : see reference to class template instantiation 'TNL::RefPtr<T>' being compiled
        with
        [
            T=TNL::AsymmetricKey
        ]

As soon as I remove the dllexport flag, it will compile fine. TNL::NetInterface is the only class we have noticed the error with. If I subclass TNL::Object, for example, it will export just fine.

This is very weird. Why a compile error, specifically involving the RefPtr class?? Could anyone shed some light?

#1
06/22/2006 (3:02 pm)
Wow this was bad. The problem is that when exporting NetInterface, it has RefPtrs containing both AsymmetricKey and Certificate. These classes are only stubbed in the actual tnlNetInterface.h header!! To fix the issue, you must explicitly include tnlAsymmetricKey.h and tnlCertificate.h in the header file of your derived class.