I've been working on how to use OGRE and the process has been challenging. I looked at the documentation on the website but it wasn't as clear as I hoped. The place to start seemed to be "Installing the OGRE SDK".
I downloaded OGRE SDK MinGW 1.7.2 for MinGW and extracted it to:
%HOME%\dep\ogre
I initialized OGRE_HOME:
set OGRE_HOME=%HOME%\dep\ogre
I downloaded and installed DirectX End User Runtime (August 2009).
The next step seemed to be "Basic Tutorial 1". There was way too much information here.
The next placed to go seemed to be "Ogre Wiki Tutorial Framework". Again there was way too much information. I wanted to get a minimal application up and running.
I downloaded Tutorial Framework - (Windows Line-endings).
The thing I needed now was how to build this code. "Building Your Projects with CMake" seemed useful. I copied and pasted the code into CMakeLists.txt.
(Double click code to select all.)
#/* #----------------------------------------------------------------------------- #Filename: CMakeLists.txt #----------------------------------------------------------------------------- # #This source file is part of the # ___ __ __ _ _ _ # /___\__ _ _ __ ___ / / /\ \ (_) | _(_) # // // _` | '__/ _ \ \ \/ \/ / | |/ / | #/ \_// (_| | | | __/ \ /\ /| | <| | #\___/ \__, |_| \___| \/ \/ |_|_|\_\_| # |___/ # Tutorial Framework # http://www.ogre3d.org/tikiwiki/ #----------------------------------------------------------------------------- #*/ cmake_minimum_required(VERSION 2.6) project(OgreApp) if(WIN32) set(CMAKE_MODULE_PATH "$ENV{OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}") set(OGRE_SAMPLES_INCLUDEPATH $ENV{OGRE_HOME}/Samples/include ) endif(WIN32) if(UNIX) set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}") set(OGRE_SAMPLES_INCLUDEPATH /usr/local/share/OGRE/samples/Common/include/ ) endif(UNIX) if (CMAKE_BUILD_TYPE STREQUAL "") # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up # differentiation between debug and release builds. set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) endif () set(CMAKE_DEBUG_POSTFIX "_d") set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dist") find_package(OGRE REQUIRED) if(NOT "${OGRE_VERSION_NAME}" STREQUAL "Cthugha") message(SEND_ERROR "You need Ogre 1.7 Cthugha to build this.") endif() find_package(OIS REQUIRED) if(NOT OIS_FOUND) message(SEND_ERROR "Failed to find OIS.") endif() # Find Boost if (NOT OGRE_BUILD_PLATFORM_IPHONE) if (WIN32 OR APPLE) set(Boost_USE_STATIC_LIBS TRUE) else () # Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit set(Boost_USE_STATIC_LIBS ${OGRE_STATIC}) endif () if (MINGW) # this is probably a bug in CMake: the boost find module tries to look for # boost libraries with name libboost_*, but CMake already prefixes library # search names with "lib". This is the workaround. set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") endif () set(Boost_ADDITIONAL_VERSIONS "1.42" "1.42.0" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" ) # Components that need linking (NB does not include header-only components like bind) set(OGRE_BOOST_COMPONENTS thread date_time) find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET) if (NOT Boost_FOUND) # Try again with the other type of libs set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS}) find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET) endif() find_package(Boost QUIET) # Set up referencing of Boost include_directories(${Boost_INCLUDE_DIR}) add_definitions(-DBOOST_ALL_NO_LIB) set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES}) endif() set(HDRS ./BaseApplication.h ./TutorialApplication.h ) set(SRCS ./BaseApplication.cpp ./TutorialApplication.cpp ) include_directories( ${OIS_INCLUDE_DIRS} ${OGRE_INCLUDE_DIRS} ${OGRE_SAMPLES_INCLUDEPATH} ) add_executable(OgreApp WIN32 ${HDRS} ${SRCS}) set_target_properties(OgreApp PROPERTIES DEBUG_POSTFIX _d) target_link_libraries(OgreApp ${OGRE_LIBRARIES} ${OIS_LIBRARIES}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/bin) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/media) # post-build copy for win32 if(WIN32 AND NOT MINGW) add_custom_command( TARGET OgreApp PRE_BUILD COMMAND if not exist .\\dist\\bin mkdir .\\dist\\bin ) add_custom_command( TARGET OgreApp POST_BUILD COMMAND copy \"$(TargetPath)\" .\\dist\\bin ) endif(WIN32 AND NOT MINGW) if(MINGW) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/dist/bin) endif(MINGW) if(WIN32) install(TARGETS OgreApp RUNTIME DESTINATION bin CONFIGURATIONS All) install(DIRECTORY ${CMAKE_SOURCE_DIR}/dist/Media DESTINATION ./ CONFIGURATIONS Release RelWithDebInfo Debug ) install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins.cfg ${CMAKE_SOURCE_DIR}/dist/bin/resources.cfg DESTINATION bin CONFIGURATIONS Release RelWithDebInfo ) install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins_d.cfg ${CMAKE_SOURCE_DIR}/dist/bin/resources_d.cfg DESTINATION bin CONFIGURATIONS Debug ) install(FILES ${OGRE_PLUGIN_DIR_REL}/OgreMain.dll ${OGRE_PLUGIN_DIR_REL}/RenderSystem_Direct3D9.dll ${OGRE_PLUGIN_DIR_REL}/RenderSystem_GL.dll ${OGRE_PLUGIN_DIR_REL}/OIS.dll DESTINATION bin CONFIGURATIONS Release RelWithDebInfo ) install(FILES ${OGRE_PLUGIN_DIR_DBG}/OgreMain_d.dll ${OGRE_PLUGIN_DIR_DBG}/RenderSystem_Direct3D9_d.dll ${OGRE_PLUGIN_DIR_DBG}/RenderSystem_GL_d.dll ${OGRE_PLUGIN_DIR_DBG}/OIS_d.dll DESTINATION bin CONFIGURATIONS Debug ) endif(WIN32)
I ran:
cmake -G "MinGW Makefiles"
and got the error message:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: Boost_INCLUDE_DIR (ADVANCED) used as include directory in directory E:/agi/nguyen/TutorialFramework -- Configuration incomplete, errors occurred!
Looking around, I found CMake message.
I fixed this by:
set BOOST_ROOT=%HOME%/dep/boost
I tried generating a Makefile again.
cmake -G "MinGW Makefiles"
Success!
I tried building next.
mingw32-make
Success!
I tried installing next:
mingw32-make install
and got the error message:
CMake Error at cmake_install.cmake:50 (FILE): file INSTALL cannot find "E:/agi/nguyen/TutorialFramework/dist/bin/plugins.cfg". mingw32-make: *** [install] Error 1
I copied: agi/dep/ogre/bin/release/plugins.cfg
to: agi/nguyen/TutorialFramework/dist/binh/plugins.cfg
I tried installing again:
mingw32-make install
and got the error message:
CMake Error at cmake_install.cmake:50 (FILE): file INSTALL cannot find "E:/agi/nguyen/TutorialFramework/dist/bin/resources.cfg". mingw32-make: *** [install] Error 1
I copied: agi/dep/ogre/bin/release/resources.cfg
to: agi/nguyen/TutorialFramework/dist/binh/resources.cfg
I tried installing again:
mingw32-make install
and got the error message:
CMake Error at cmake_install.cmake:68 (FILE): file INSTALL cannot find "E:/agi/dep/ogre/bin/relase/OIS.dll". mingw32-make: *** [install] Error 1
I changed CMakeLists.txt from:
${OGRE_PLUGIN_DIR_REL}/OIS.dll
to:
${OGRE_PLUGIN_DIR_REL}/libOIS.dll
I tried installing again:
mingw32-make install
Success!
I tried running: OgreApp.exe and got the error message
Runtime Error 1: OgreApp.exe - Entry Point Not Found The procedure entry point _ZNst9exceptionD2Ev could not be located in the dynamic link library libstdc++-6.dll.
I've been using MinGW that came with Qt SDK Win Open Source 2010.02.1. The GCC version that came with that was 4.5.4. The Prerequisites page notes that OGRE 1.7.2 requires Twilight Dragon Media's MinGW. I suspect that the libstdc++-6.dll files are different.
I installed TDM MinGW with the following packages:
- gcc (TDM-GCC Current: 4.5.1-tdm-1)
- binutils (MinGW Stable: 2.20.51-1)
- mingw-runtime (MinGW Stable: 3.18)
- w32api (MinGW Stable: 3.14)
- mingw32-make (MinGW Stable: 3.82-3)
- gdb (MinGW Stable: 7.1-2)
I compiled with TDM MinGW, ran OgreApp.exe got the error:
cc1plus.exe - Unable to Locate Component The application has failed to start because libgmp-3.dll was not found. Re-installing the application may fix this problem.
I used TDM MinGW installer and added OpenMP support but it only added libgomp-1.dll. I suspected that the CMake files were still referring to Qt MinGW and not TDM MinGW. I deleted the CMake generated files and generated new CMake files.
I built the Tutorial Framework, ran OgreApp.exe and got a new error:
OgreApp.exe - Entry Point Not Found The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll
There was a mention somewhere that OGRE 1.7.2 had moved from TDM MinGW to Official MinGW. I ran the TDM MinGW installer and switched to Official MinGW.
I compiled, ran OgreApp.exe and got a new error:
OgreApp.exe - Entry Point Not Found This application has failed to start because libboost_thread-mgw45-mt-1_44.dll was not found. Re-installing this application may fix this problem.
I realized I had not built the Boost Thread library.
To show which libraries you can build:
bjam toolset=gcc --show-libaries
To build:
bjam toolset=gcc --with-thread stage
For building Boost, I thought I'd stick with Qt MinGW but that produced:
boost_thread-mgw44-1_42.dll
What I needed was:
libboost_thread-mgw45-mt-1_44.dll
- The MinGW version was different.
- The Boost version was different.
- The threading version was different.
- The file name was different.
I needed to upgrade Boost from 1.42 to 1.44, to upgrade GCC from 4.5.5, and build with multi-threading.
I had a look around and found "Building Boost BCP".
The following switches were useful:
- variant=debug|release
- link=shared|static
- threading=multi|single
I downloaded Boost 1.44.
I tried
bjam toolset=gcc --with-thread link=shared stage
I ran OgreApp.exe and got a new error:
An exception has occurred! OGRE EXCEPTION(7:InternalErrorException): Could not load dynamic library .\Plugin_ParticleFX. System Error: The specified module could not be found. in DynLib::load at ../../../../../OgreMain/src/OgreDynLib.cpp (line 91)
Fix:
I copied over from agi/dep/ogre/release
- Plugin_ParticleFX.dll
to:
agi/nguyen/TutorialFramework/dist/bin
I ran OgreApp.exe and kept copying over more DLL files.
- Plugin_BSPSceneManager.dll
- Plugin_CgProgramManager.dll
- cg.dll
- Plugin_PCZSceneManager.dll
- Plugin_OctreeZone.dll
- Plugin_OcttreeSceneManager.dll
I ran OgreApp.exe and got a new error message:
An exception has occurred! OGRE EXCEPTION(7:InternalErrorException): ../../media/packs/SDKTrays.zip - error whilst opening archive: Unable to read zip file. in ZipArchive::checkZzip at ../../../../../OgreMain/src/Ogreip.cpp (line 280)
I copied:
agi/ogre/media/SdkTrays.zip
to:
agi/nguyen/TutorialFramework/media/packs/SdkTrays.zip
I ran OgreApp.exe:
Success!
Thoughts
- Reading the documentation would probably have helped but the problem was determining what to read and where.
- The process was challenging and I did get frustrated but I remembered that all this sophisticated software was free and to be grateful the error messages were good enough to guide me along.
- I still believe that there has to be an easier way to get started with OGRE.
- I'll write this up in a "How to" type post soon.
- I'd also like to have a go at the other tutorial frameworks.
- OGRE should have a tutorial that shows users how to set up a basic program from start to finish. I realize this is hard because of the different tools involved.
- This is the part I hate about software development, setting the environment up. The other part I hate is learning new frameworks and syntax. The best part is when you've moved past all that.
- I wish there was an easier way. Ubuntu Linux does make things easier but I want more insight into what happens in the background and more control over the process.
- It would be great if people could just download a configurable development environment and just get going.
Hmm, so you're still using MinGW for compiling your projects... Have you tried getting Polyworld to work on VS2010?
ReplyDeleteAlso, are you going to release your code, or do you have a sourceforge/etc account?
Hi Anonymous,
ReplyDeleteI'm still building Polyworld with MinGW and I haven't tried building with VS2010. The reason used to be that Polyworld uses Qt and open source Qt did not support Visual Studio. However, open source Qt 4.3.2 onwards now does support Visual Studio.
Polyworld still uses Qt's qmake to generate Makefiles but I don't know how to use qmake to generate Visual Studio files.
For Polyworld to work with Visual Studio, I'll have to learn to use qmake to generate Visual Studio files. The alternative is to move Polyworld away from Qt so I can use CMake to generate both MinGW and Visual Studio files.
I've been working with a friend and we've been discussing releasing the code. I've been basically working off a version of Polyworld from about a year ago and I don't know what the open source license require me to do. The likely plan is to put up monthly code releases as soon as I can change the graphics system to OGRE.
If you're interested I can put up the version I'm currently working on.
Hmm, using Qt to generate Makefiles is just a matter of changing the makespecs. That's what it seems like at least.
ReplyDeleteHi. Thanks for this guide - it was really helpful. I am not sure if I could manage amount of frustration provided by Ogre and deal with all those problems myself before wiping the SDK out of my disk ;)
ReplyDeleteSadly, your post is now almost 2 years old and nothing really changed - same or similar problems still exist.