I've been developping with Ogre for a few months now, and I have an Ogre application that works under linux (ubuntu) with a CMake build linked to Eclipse CDT seamlessly.
However I tried all day to build my application under Windows XP and have had no luck so far...
I downloaded the SDK (ogresdk_vc9_v1-7-3) from the official SourceForge repository, I have set the OGRE_HOME env variable correctly, I needed a few hours to tweak the CMake file (see below) because I first had a bug with ${Boost_LIBRARIES}, then with CEGUI libs.
Now this is the procedure I follow to build my app :
I run CMake, I open 'OgreApp.vcproj' with VC9Express, then I build the target 'OgreApp' and I get the error :
I am pretty sure this is just about to work properly but I really need help2>Linking...
2>LINK : fatal error LNK1104: cannot open file 'OgreGUIRenderer.lib'
2>Build log was saved at "file://c:\clean_ogre_cmake_project_build\OgreApp.dir\Release\BuildLog.htm"
2>OgreApp - 1 error(s), 23 warning(s)
Any help appreciated,
Guillaume
My tweaked CMake file :
Code: 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(Engine3)
if (WIN32)
# - Locate CEGUI library
# This module defines
# CEGUI_LIBRARY, the library to link against
# CEGUI_FOUND, if false, do not try to link to CEGUI
# CEGUI_INCLUDE_DIRS, where to find headers.
IF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS)
# in cache already
SET(CEGUI_FIND_QUIETLY TRUE)
ENDIF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS)
FIND_PATH(CEGUI_INCLUDE_DIRS
CEGUI
PATHS
$ENV{CEGUI_DIR}/include
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
C:/CEGUI-SDK-0.7.5-vc9/cegui
PATH_SUFFIXES cegui CEGUI
)
FIND_LIBRARY(CEGUI_LIBRARY
NAMES CEGUIBase
PATHS
$ENV{CEGUI_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
C:/CEGUI-SDK-0.7.5-vc9/lib
)
IF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS)
SET(CEGUI_FOUND "YES")
SET(CEGUI_INCLUDE_DIRS "${CEGUI_INCLUDE_DIRS}/CEGUI")
IF(NOT CEGUI_FIND_QUIETLY)
MESSAGE(STATUS "Found CEGUI: ${CEGUI_LIBRARY}")
ENDIF(NOT CEGUI_FIND_QUIETLY)
ELSE(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS)
IF(NOT CEGUI_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find CEGUI!")
ENDIF(NOT CEGUI_FIND_QUIETLY)
ENDIF(CEGUI_LIBRARY AND CEGUI_INCLUDE_DIRS)
endif(WIN32)
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)
if(EXISTS "/usr/local/lib/OGRE/cmake")
set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
set(OGRE_SAMPLES_INCLUDEPATH "/usr/local/share/OGRE/samples/Common/include/") # We could just *assume* that developers uses this basepath : /usr/local
elseif(EXISTS "/usr/lib/OGRE/cmake")
set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
set(OGRE_SAMPLES_INCLUDEPATH "/usr/share/OGRE/samples/Common/include/") # Otherwise, this one
else ()
message(SEND_ERROR "Failed to find module path.")
endif(EXISTS "/usr/local/lib/OGRE")
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.44" "1.44.0" "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
set (Boost_INCLUDE_DIR C:/OgreSDK_vc9_v1-7-2/boost_1_44)
include_directories(${Boost_INCLUDE_DIR})
add_definitions(-DBOOST_ALL_NO_LIB)
set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES} ${CEGUI_LIBRARY})
endif()
set(HDRS
abstractentity.h
arbitrator.h
BaseApplication.h
camera.h
collection.h
freeview.h
function.h
functions.h
keyboard.h
localset.h
mouse.h
ogretext.h
parser.h
physics.h
pivot.h
terrain.h
TutorialApplication.h
variable.h
vector.h
accessible.h
abool.h
afloat.h
astring.h
error.h
animstate.h
declaredfunction.h
pointLight.h
light.h
codetrimmer.h
enginemaths.h
acollection.h
)
set(SRCS
abstractentity.cpp
arbitrator.cpp
BaseApplication.cpp
camera.cpp
collection.cpp
freeview.cpp
function.cpp
functions.cpp
keyboard.cpp
localset.cpp
mesh.cpp
mouse.cpp
parser.cpp
physics.cpp
pivot.cpp
terrain.cpp
TutorialApplication.cpp
variable.cpp
vector.cpp
accessible.cpp
abool.cpp
afloat.cpp
astring.cpp
error.cpp
animstate.cpp
declaredfunction.cpp
pointLight.cpp
light.cpp
codetrimmer.cpp
enginemaths.cpp
acollection.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 OR UNIX)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/dist/bin)
endif(MINGW OR UNIX)
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
)
# NOTE: for the 1.7.1 sdk the OIS dll is called OIS.dll instead of libOIS.dll
# so you'll have to change that to make it work with 1.7.1
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}/libOIS.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}/libOIS_d.dll
DESTINATION bin
CONFIGURATIONS Debug
)
# as of sdk 1.7.2 we need to copy the boost dll's as well
# because they're not linked statically (it worked with 1.7.1 though)
install(FILES ${Boost_DATE_TIME_LIBRARY_RELEASE}
${Boost_THREAD_LIBRARY_RELEASE}
DESTINATION bin
CONFIGURATIONS Release RelWithDebInfo
)
install(FILES ${Boost_DATE_TIME_LIBRARY_DEBUG}
${Boost_THREAD_LIBRARY_DEBUG}
DESTINATION bin
CONFIGURATIONS Debug
)
endif(WIN32)
if(UNIX)
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 Debug
)
endif(UNIX)