[Solved] Problem Compiling Caelum v0.4

dredogol

30-05-2009 21:18:02

Alright, I DLed the Caelum source SVN repisotyr...
I opened up a new Ogre3D SDK project with MSVS C++ 2009.

What I did was create a new folder called "Caelum" inside my (inc), (resource) and (src) folders.
Next, I copied all the original Caelum .h and .cpp files into those folders
Then, I copied the CaelumDemo.cpp and .h files into the top (inc) and (src) folders.

Folder Structures:
Project Folder
> inc
>>> CaelumDemo.h
>>> CaelumDemoCommon.h
>>> [Caelum_Folder]
>>>>>> All necessary .h files...
> resource
>>> whatever the default project stuff is...
> src
>>> CaelumDemo.cpp
>>> [Caelum_Folder]
>>>>>> All necessary .cpp files...

After that, in my project, I created new Filters, and added the original Caelum files into them.

However, since the #include "Caelum.h" is located in a folder, I had to change it to: #include "Caelum\Caelum.h"

After that, I tried to build the program in Release build, I got some massive linking errors:
1>------ Build started: Project: Caelum_Test, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>CaelumDemo.cpp
1>Linking...
1>LINK : warning LNK4224: /OPT:NOWIN98 is no longer supported; ignored
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: float __thiscall Caelum::UniversalClock::getTimeScale(void)const " (__imp_?getTimeScale@UniversalClock@Caelum@@QBEMXZ)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall Caelum::UniversalClock::setTimeScale(float)" (__imp_?setTimeScale@UniversalClock@Caelum@@QAEXM@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl Caelum::Astronomy::getGregorianDateTimeFromJulianDay(double,int &,int &,int &,int &,int &,double &)" (__imp_?getGregorianDateTimeFromJulianDay@Astronomy@Caelum@@SAXNAAH0000AAN@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl Caelum::Astronomy::getGregorianDateFromJulianDay(int,int &,int &,int &)" (__imp_?getGregorianDateFromJulianDay@Astronomy@Caelum@@SAXHAAH00@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static double __cdecl Caelum::Astronomy::getJulianDayFromGregorianDateTime(int,int,int,int,int,double)" (__imp_?getJulianDayFromGregorianDateTime@Astronomy@Caelum@@SANHHHHHN@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static int __cdecl Caelum::Astronomy::getJulianDayFromGregorianDate(int,int,int)" (__imp_?getJulianDayFromGregorianDate@Astronomy@Caelum@@SAHHHH@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl Caelum::Astronomy::getHorizontalMoonPosition(double,double,double,double &,double &)" (__imp_?getHorizontalMoonPosition@Astronomy@Caelum@@SAXNNNAAN0@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl Caelum::Astronomy::getHorizontalSunPosition(double,double,double,double &,double &)" (__imp_?getHorizontalSunPosition@Astronomy@Caelum@@SAXNNNAAN0@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual void __thiscall Caelum::CaelumSystem::preViewportUpdate(struct Ogre::RenderTargetViewportEvent const &)" (__imp_?preViewportUpdate@CaelumSystem@Caelum@@EAEXABURenderTargetViewportEvent@Ogre@@@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual bool __thiscall Caelum::CaelumSystem::frameStarted(struct Ogre::FrameEvent const &)" (__imp_?frameStarted@CaelumSystem@Caelum@@EAE_NABUFrameEvent@Ogre@@@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall Caelum::CaelumSystem::shutdown(bool)" (__imp_?shutdown@CaelumSystem@Caelum@@QAEX_N@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Caelum::CaelumSystem::~CaelumSystem(void)" (__imp_??1CaelumSystem@Caelum@@UAE@XZ)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall Caelum::CaelumSystem::CaelumSystem(class Ogre::Root *,class Ogre::SceneManager *,enum Caelum::CaelumSystem::CaelumComponent)" (__imp_??0CaelumSystem@Caelum@@QAE@PAVRoot@Ogre@@PAVSceneManager@3@W4CaelumComponent@01@@Z)
1>CaelumDemo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class Caelum::UniversalClock * __thiscall Caelum::CaelumSystem::getUniversalClock(void)const " (__imp_?getUniversalClock@CaelumSystem@Caelum@@QBEPAVUniversalClock@2@XZ)
1>MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
1>bin\Release\Caelum_Test.exe : fatal error LNK1120: 15 unresolved externals
1>Build log was saved at "file://g:\+ Ogre Projects\Caelum_Test\obj\Release\BuildLog.htm"
1>Caelum_Test - 16 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I really hate linking errors, and I really can't seem to figure them out very well.
Could someone please tell me if I'm missing a step somewhere, or what might be wrong?

The only thing I changed was the CaelumDemoCommon.h file, where I changed the #include to point to the correct folder to find the Caelum.h file.

dredogol

31-05-2009 15:32:50

Alright, I manged to fix the error, and this fix also applies to the post:
error PRJ0019 compiling CaelumDemo originally by hellzakk
http://www.ogre3d.org/addonforums/viewtopic.php?f=21&t=10136

You need to change your MAIN() function, because it is old, and we're using C++. The IDE / compiler doesn't like the C version I guess...
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
#else
int main(int argc, char **argv)
#endif
{
try
{
CaelumSampleApplication app;
app.go ();
}
catch(std::exception& e)
{
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBoxA(NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n", e.getFullDescription().c_str());
#endif
}

return 0;
}