NOTE: This is the 3rd time that I've written because the board suggested that I've got to refresh the page before replying. Dammit. Why won't the board cache the message with a script so that it wasn't lost in the process? I'm so lazy rewriting the whole thing again.
Ok, here goes my reply:
Actually this happens when I'm trying to work with Delta3D, an open source engine. The original projects actually have the exporting preprocessor so they should be choosing #define DLL_EXPORT __declspec(dllexport) instead of #define DLL_EXPORT __declspec(dllimport), right? But I don't know why all of them just assume that it wasn't defined in the first place and choses the dllimport instead (or the "#else" block).
I've been meddling with 2 of its base / core projects, dtUtil and dtCore. dtCore uses dtUtil as its dependency while dtUtil uses external pre compiled dependencies like Open Scene Graphe, ODE, xerces, etc.
I've tried changing dtUtil/export.h:
Code:
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
# ifdef DT_UTIL_LIBRARY
# define DT_UTIL_EXPORT __declspec(dllexport)
# else
# define DT_UTIL_EXPORT __declspec(dllexport)
//# define DT_UTIL_EXPORT __declspec(dllimport)
# endif
#else
# ifdef DT_UTIL_LIBRARY
# define DT_UTIL_EXPORT __attribute__ ((visibility("default")))
# else
# define DT_UTIL_EXPORT
# endif
#endif
AND dtCore/export.h:
Code:
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
# ifdef DT_CORE_LIBRARY
# define DT_CORE_EXPORT __declspec(dllexport)
# else
# define DT_CORE_EXPORT __declspec(dllexport)
//# define DT_CORE_EXPORT __declspec(dllimport)
# endif
#else
# ifdef DT_CORE_LIBRARY
# define DT_CORE_EXPORT __attribute__ ((visibility("default")))
# else
# define DT_CORE_EXPORT
# endif
#endif
so that those two will be forced to use dllexport instead.
FYI the DT_UTIL_LIBRARY and DT_CORE_LIBRARY are defined in their respective projects' preprocessor. But as you can see, they choose the "#else" block instead. Why does this happen?
Without the hack, the library can actually be built just fine but using the hack, this happened: dtUtil can be built, but dtCore can't and displayed lots of LNK2001 and LNK2019 errors (up to 53 errors). These are a few of them:
Code:
Error 9 error LNK2001: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::BaseExceptionType::mGenericInstances" (?mGenericInstances@BaseExceptionType@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) shaderprogram.obj
Error 10 error LNK2001: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::BaseExceptionType::mGenericInstances" (?mGenericInstances@BaseExceptionType@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) shaderxml.obj
Error 11 error LNK2019: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::BaseExceptionType::mGenericInstances" (?mGenericInstances@BaseExceptionType@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) referenced in function __unwindfunclet$??0?$has_slots@Vmulti_threaded_local@sigslot@@@sigslot@@QAE@XZ$0 singletonmanager.obj
Error 12 error LNK2001: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::BaseExceptionType::mGenericInstances" (?mGenericInstances@BaseExceptionType@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) view.obj
Error 33 error LNK2001: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::DateTime::TimeOrigin::mGenericInstances" (?mGenericInstances@TimeOrigin@DateTime@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) camera.obj
Error 34 error LNK2019: unresolved external symbol "private: static class std::vector<class dtUtil::Enumeration *,class std::allocator<class dtUtil::Enumeration *> > dtUtil::DateTime::TimeOrigin::mGenericInstances" (?mGenericInstances@TimeOrigin@DateTime@dtUtil@@0V?$vector@PAVEnumeration@dtUtil@@V?$allocator@PAVEnumeration@dtUtil@@@std@@@std@@A) referenced in function "public: void __thiscall dtCore::Transform::GetTranslation(class osg::Vec3f &)const " (?GetTranslation@Transform@dtCore@@QBEXAAVVec3f@osg@@@Z) environment.obj
So what happened here? Thanks.