In my case I write a Kernel.dll
which wraps CxImage object(either CxImageJPG or CxImage) defined in xImage.dll
which shared with other binary modules(no sourcecode):
class CCxImageWraper{
public:
shared_ptr<CxImage> m_spImage;
...
}
when I use a dynamic_cast it fails with std::__non_rtti_object
exception:
m_spImage.reset(new CxImageJPG); // always std::__non_rtti_object exception
CxImageJPG* cxJpgImage = dynamic_cast<CxImageJPG*>(m_spImage.get());
I'm sure that kernal.dll
project use the option /GR (Enable Run-Time Type Information)
, and the pointer m_spImage.get()
here is not NULL and it is surely point to a CxImageJPG
instatance. Don't know why it throws std::__non_rtti_object Is any information I was missing?
I did try create a new console project Test.exe
and TestDll.dll
, Test.exe
always turn on GR
switch, TestDll.dll
has two class: BaseClass
, SubClass
, whatever option I set to TestDll.dll
: /GR
or /GR-
, /MT
or /MDd
or /MTd
. Test.exe always can dynamic_cast the object defined in TestDll.dll
:
boost::shared_ptr<BaseClass> spItem(new SubClass());
SubClass* pClass = dynamic_cast<SubClass*>(spItem.get()); // always no exception
Aready checked problem, but can't find more information to my problem: