Linker error during Windows CMake build

Problems building or running the engine, queries about how to use features etc.
Post Reply
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Linker error during Windows CMake build

Post by guillaumequest »

Hi there,
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 :
2>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)
I am pretty sure this is just about to work properly but I really need help :(

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)
 
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Up please ! If you need any additional information just ask...
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Linker error during Windows CMake build

Post by CABAListic »

Not sure where it's coming from, but OgreGUIRenderer.lib is outdated. This was when Ogre included the CEGUI renderer, but it no longer does. The Ogre CEGUI renderer is now shipped with CEGUI, and it's called CEGUIOgreRenderer (or something like that), so you need to find where it picks up the wrong library name and fix it.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Thanks for your reply !
I don't think it can be in Ogre itself because I'm pretty sure I have the lastest version, and I also tried building my app against a version of Ogre I build myself. I guess it could come from CEGUI itself although once again I'm pretty sure I got the right version.

How does the vc9 build knows which Ogre SDK it should choose ? I suppose it is defined by %OGRE_HOME% but is it read during CMake or during the linking itself ?

I guess I should try a clean install. Do you suggest I re-build Ogre too for this ?

Thanks for your help,
Guillaume
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

And btw, can I build my Ogre application (that doesn't need much more than what the TutorialApplication does) without CEGUI ?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Where did you get that CMake script?
Try this:
http://www.ogre3d.org/tikiwiki/Building ... With+CMake
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

I got this one and added a few tweaks because I got errors complaining about finding CEGUI (which I don't even need) and boost (there seem to be a mismatch between versions 1_42 and 1_44
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Why the fuck is there CEGUI in the CMake script??
From where did you get it?

Use the one I linked to, or you are on your own.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

If you still get those errors after switch to using the new CMakeLists.txt, then delete the CMakeCache.txt in your build directory and rerun CMake..
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

jacmoe wrote:Why the fuck is there CEGUI in the CMake script??
Got the one you mentionned and tweaked it to include CEGUI (I had CEGUI-related errors even though I never mentionned CEGUI in my project).
jacmoe wrote:Use the one I linked to, or you are on your own.
Okay, I grabbed the one you linked to, ran CMake-gui, File->delete cache, Configure for Visual Studio 9 2008, and I ran into this error in CMake upon configure :
Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Looking for OGRE...
OGRE_PREFIX_WATCH changed.
Found Ogre Cthugha (1.7.2)
Found OGRE: optimized;C:/OgreSDK_vc10_v1-7-2/lib/release/OgreMain.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/debug/OgreMain_d.lib
Looking for OGRE_Paging...
Found OGRE_Paging: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgrePaging.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgrePaging_d.lib
Looking for OGRE_Terrain...
Found OGRE_Terrain: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreTerrain.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreTerrain_d.lib
Looking for OGRE_Property...
Found OGRE_Property: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreProperty.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreProperty_d.lib
Looking for OGRE_RTShaderSystem...
Found OGRE_RTShaderSystem: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreRTShaderSystem.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreRTShaderSystem_d.lib
Looking for OIS...
OIS_PREFIX_PATH changed.
Found OIS: optimized;C:/OgreSDK_vc10_v1-7-2/lib/release/OIS.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/debug/OIS_d.lib
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 C:/clean_ogre_cmake_project
Last time I ran into this error I 'solved' it by adding the line :

Code: Select all

set (Boost_INCLUDE_DIR C:/OgreSDK_vc9_v1-7-2/boost_1_44)
in the CMake file although I know it is very ugly. Any suggestions ?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

It's good enough :)
http://www.ogre3d.org/tikiwiki/Prerequisites#Boost
Can't see much of a difference between hardcoding it in the CMake script or as an environment variable.
Except that if you're using the latter, you don't need to write it in each of your CMake scripts. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Got it !

The CMake script says 'Boost_INCLUDE_DIR' but the prerequisites page says 'BOOST_INCLUDEDIR'

However the build didn't go too well :
1>------ Build started: Project: OgreApp, Configuration: Debug Win32 ------
1>Performing Pre-Build Event...
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'CEGUIBase_d.lib'
1>Build log was saved at "file://c:\clean_ogre_cmake_project_build\OgreApp.dir\Debug\BuildLog.htm"
1>OgreApp - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
So I'm back to the problem that induced me into including CEGUI in the CMake script...
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Try using a proper find CEGUI cmake script, like this:

Code: Select all

#
# Try to find Cegui library on both Windows and Linux systems
# 
# The following values will get defined:
#	CEGUI_FOUND - True if cegui lib was found
#	CEGUI_INCLUDE_DIR - Include libraries for cegui usage
#	CEGUI_LIBRARIES - Library paths for cegui
#
# Please set your environmental variables to include CEGUI_HOME, which should point to the CEGUI SDK
#
SET(CEGUI_FOUND "No")
MARK_AS_ADVANCED(CEGUI_FOUND)

IF (UNIX)
    SET(CEGUI_INC_SEARCH_PATH
	/usr/include/cegui
	/usr/include/CEGUI
	/usr/include/OGRE
	/usr/local/include/cegui
	/usr/local/include/CEGUI
     )
     
     SET(CEGUI_LIB_SEARCH_PATH
        /lib
        /usr/lib
	/usr/lib32
	/usr/lib64
	/usr/local/lib
	/usr/local/lib32
	/usr/local/lib64
     )
 
	SET(CEGUIBASE_LIBNAMES CEGUIBase)
	SET(CEGUI_LIBNAMES CEGUIOgreRenderer OgreGUIRenderer)
ENDIF(UNIX)


IF(WIN32)
    # For the OgreSDK should be the prefared place to get the CEGUI files
    # The samples line is there to help building with the standard setup (Missing OgreCEGUIRenderer.h)

    SET(CEGUI_INC_SEARCH_PATH
	$ENV{OGRE_HOME}/include
	$ENV{OGRE_HOME}/include/CEGUI
	$ENV{OGRE_HOME}/samples/include
	$ENV{CEGUI_HOME}/include
	$ENV{CEGUI_HOME}/include/CEGUI
	$ENV{CEGUI_EXTRA_INCLUDE_DIR}
	$ENV{CEGUI_EXTRA_INCLUDE_DIR}/include
     )
     
     SET(CEGUI_LIB_SEARCH_PATH
	$ENV{OGRE_HOME}/lib
	$ENV{OGRE_HOME}/bin
	$ENV{OGRE_HOME}/bin/debug
	$ENV{OGRE_HOME}/bin/release
	$ENV{CEGUI_HOME}/lib
	$ENV{CEGUI_HOME}/bin
	$ENV{CEGUI_HOME}/bin/debug
	$ENV{CEGUI_HOME}/bin/release
	/OgreSDK/lib
	/OgreSDK/bin
	/OgreSDK/bin/debug
	/OgreSDK/bin/release
     )

	IF(MSVC)
		SET(CEGUI_LIBNAMES_DEB CEGUIOgreRenderer_d OgreGUIRenderer_d)	
		SET(CEGUI_LIBNAMES_REL CEGUIOgreRenderer OgreGUIRenderer)
		SET(CEGUIBASE_LIBNAMES_DEB CEGUIBase_d)	
		SET(CEGUIBASE_LIBNAMES_REL CEGUIBase)	
	ELSE(MSVC)
		SET(CEGUI_LIBNAMES CEGUIOgreRenderer OgreGUIRenderer)
		SET(CEGUIBASE_LIBNAMES CEGUIBase)	
	ENDIF(MSVC)
ENDIF(WIN32)

SET(CEGUI_ALL_FOUND 1)

# Include paths search
FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h ${CEGUI_INC_SEARCH_PATH})

IF(NOT CEGUI_INCLUDE_DIR)
	MESSAGE("WARNING: CEGUI.h not found under ${CEGUI_INC_SEARCH_PATH}")
	SET(CEGUI_ALL_FOUND 0)
ENDIF(NOT CEGUI_INCLUDE_DIR)

# Include paths search, renderer
FIND_PATH(CEGUI_EXTRA_INCLUDE_DIR OgreCEGUIRenderer.h ${CEGUI_INC_SEARCH_PATH})

IF(NOT CEGUI_EXTRA_INCLUDE_DIR)
	MESSAGE("WARNING: OgreCEGUIRenderer.h not found under ${CEGUI_INC_SEARCH_PATH}")
	SET(CEGUI_ALL_FOUND 0)
ENDIF(NOT CEGUI_EXTRA_INCLUDE_DIR)

# Cegui ogre renderer library
# Target compiler specific, as MSVC holds Debug and release separate
IF(MSVC)
	# Cegui library
	FIND_LIBRARY(CEGUI_CEGUI_LIB_RELEASE NAME ${CEGUIBASE_LIBNAMES_REL} PATHS ${CEGUI_LIB_SEARCH_PATH})
	FIND_LIBRARY(CEGUI_CEGUI_LIB_DEBUG NAME ${CEGUIBASE_LIBNAMES_DEB} PATHS ${CEGUI_LIB_SEARCH_PATH})

	IF(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)
		SET(CEGUI_CEGUI_LIB optimized ${CEGUI_CEGUI_LIB_RELEASE} debug ${CEGUI_CEGUI_LIB_DEBUG})
	ELSE(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)
		MESSAGE("WARNING: CEGUI library CEGUIBase not found under ${CEGUI_LIB_SEARCH_PATH}")
		SET(CEGUI_ALL_FOUND 0)
	ENDIF(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)

	FIND_LIBRARY(CEGUI_OGRE_LIB_RELEASE ${CEGUI_LIBNAMES_REL} PATHS ${CEGUI_LIB_SEARCH_PATH})
	FIND_LIBRARY(CEGUI_OGRE_LIB_DEBUG ${CEGUI_LIBNAMES_DEB} PATHS ${CEGUI_LIB_SEARCH_PATH})

	IF(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
		SET(CEGUI_OGRE_LIB optimized ${CEGUI_OGRE_LIB_RELEASE} debug ${CEGUI_OGRE_LIB_DEBUG})
	ELSE(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
		MESSAGE("WARNING: CEGUI OGRE library CEGUIOgreRenderer not found under ${CEGUI_LIB_SEARCH_PATH}")
		SET(CEGUI_ALL_FOUND 0)
	ENDIF(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
ELSE(MSVC)
	# Cegui library
	FIND_LIBRARY(CEGUI_CEGUI_LIB NAME ${CEGUIBASE_LIBNAMES} PATHS ${CEGUI_LIB_SEARCH_PATH})

	IF(NOT CEGUI_CEGUI_LIB)
		MESSAGE("WARNING: CEGUI library CEGUIBase not found under ${CEGUI_LIB_SEARCH_PATH}")
		SET(CEGUI_ALL_FOUND 0)
	ENDIF(NOT CEGUI_CEGUI_LIB)


	FIND_LIBRARY(CEGUI_OGRE_LIB ${CEGUI_LIBNAMES} PATHS ${CEGUI_LIB_SEARCH_PATH})

	IF(NOT CEGUI_OGRE_LIB)
		MESSAGE("WARNING: CEGUI OGRE library CEGUIOgreRenderer not found under ${CEGUI_LIB_SEARCH_PATH}")
		SET(CEGUI_ALL_FOUND 0)
	ENDIF(NOT CEGUI_OGRE_LIB)
ENDIF(MSVC)

# Extra paths for include of CEGUI (for CEGUIOgreRenderer.h)
IF(CEGUI_EXTRA_INCLUDE_DIR)
    SET(CEGUI_INCLUDE_DIR ${CEGUI_EXTRA_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR})
ENDIF(CEGUI_EXTRA_INCLUDE_DIR)

SET(CEGUI_LIBRARIES ${CEGUI_CEGUI_LIB} ${CEGUI_OGRE_LIB})

IF(CEGUI_INCLUDE_DIR AND CEGUI_CEGUI_LIB AND CEGUI_OGRE_LIB AND CEGUI_ALL_FOUND)
    SET(CEGUI_FOUND "Yes")
ENDIF(CEGUI_INCLUDE_DIR AND CEGUI_CEGUI_LIB AND CEGUI_OGRE_LIB AND CEGUI_ALL_FOUND)

MARK_AS_ADVANCED(CEGUI_INCLUDE_DIR)
MARK_AS_ADVANCED(CEGUI_LIBRARIES)
MARK_AS_ADVANCED(CEGUI_LIBNAMES)
MARK_AS_ADVANCED(CEGUI_EXTRA_INCLUDE_DIR)
MARK_AS_ADVANCED(CEGUI_CEGUI_LIB)
MARK_AS_ADVANCED(CEGUI_OGRE_LIB)
Save it as 'Find_CEGUI.cmake' and drop it in the cmake directory in the Ogre SDK.

Then put this in your CMake script:

Code: Select all

find_package(CEGUI REQUIRED)
And you can add ${CEGUI_INCLUDE_DIR} to the includes and ${CEGUI_LIBRARIES} for the linker. :wink:

Haven't actually used that script just yet, but it should probably work out of the proverbial box.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Edit : don't read below, I forgot half your instructions ^^ I'll post again when done.

Thanks for all your help.

I don't quite understand why I need CEGUI, but I don't really mind : I'm sure I'll need it later anyways.
Si I just copied your script at the beggining of the CMaje script like that :

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(OgreApp)
 
 
 
 
 
 
 
 
 #
# Try to find Cegui library on both Windows and Linux systems
# 
# The following values will get defined:
#   CEGUI_FOUND - True if cegui lib was found
#   CEGUI_INCLUDE_DIR - Include libraries for cegui usage
#   CEGUI_LIBRARIES - Library paths for cegui
#
# Please set your environmental variables to include CEGUI_HOME, which should point to the CEGUI SDK
#
SET(CEGUI_FOUND "No")
MARK_AS_ADVANCED(CEGUI_FOUND)

IF (UNIX)
    SET(CEGUI_INC_SEARCH_PATH
   /usr/include/cegui
   /usr/include/CEGUI
   /usr/include/OGRE
   /usr/local/include/cegui
   /usr/local/include/CEGUI
     )
     
     SET(CEGUI_LIB_SEARCH_PATH
        /lib
        /usr/lib
   /usr/lib32
   /usr/lib64
   /usr/local/lib
   /usr/local/lib32
   /usr/local/lib64
     )
 
   SET(CEGUIBASE_LIBNAMES CEGUIBase)
   SET(CEGUI_LIBNAMES CEGUIOgreRenderer OgreGUIRenderer)
ENDIF(UNIX)


IF(WIN32)
    # For the OgreSDK should be the prefared place to get the CEGUI files
    # The samples line is there to help building with the standard setup (Missing OgreCEGUIRenderer.h)

    SET(CEGUI_INC_SEARCH_PATH
   $ENV{OGRE_HOME}/include
   $ENV{OGRE_HOME}/include/CEGUI
   $ENV{OGRE_HOME}/samples/include
   $ENV{CEGUI_HOME}/include
   $ENV{CEGUI_HOME}/include/CEGUI
   $ENV{CEGUI_EXTRA_INCLUDE_DIR}
   $ENV{CEGUI_EXTRA_INCLUDE_DIR}/include
     )
     
     SET(CEGUI_LIB_SEARCH_PATH
   $ENV{OGRE_HOME}/lib
   $ENV{OGRE_HOME}/bin
   $ENV{OGRE_HOME}/bin/debug
   $ENV{OGRE_HOME}/bin/release
   $ENV{CEGUI_HOME}/lib
   $ENV{CEGUI_HOME}/bin
   $ENV{CEGUI_HOME}/bin/debug
   $ENV{CEGUI_HOME}/bin/release
   /OgreSDK/lib
   /OgreSDK/bin
   /OgreSDK/bin/debug
   /OgreSDK/bin/release
     )

   IF(MSVC)
      SET(CEGUI_LIBNAMES_DEB CEGUIOgreRenderer_d OgreGUIRenderer_d)   
      SET(CEGUI_LIBNAMES_REL CEGUIOgreRenderer OgreGUIRenderer)
      SET(CEGUIBASE_LIBNAMES_DEB CEGUIBase_d)   
      SET(CEGUIBASE_LIBNAMES_REL CEGUIBase)   
   ELSE(MSVC)
      SET(CEGUI_LIBNAMES CEGUIOgreRenderer OgreGUIRenderer)
      SET(CEGUIBASE_LIBNAMES CEGUIBase)   
   ENDIF(MSVC)
ENDIF(WIN32)

SET(CEGUI_ALL_FOUND 1)

# Include paths search
FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h ${CEGUI_INC_SEARCH_PATH})

IF(NOT CEGUI_INCLUDE_DIR)
   MESSAGE("WARNING: CEGUI.h not found under ${CEGUI_INC_SEARCH_PATH}")
   SET(CEGUI_ALL_FOUND 0)
ENDIF(NOT CEGUI_INCLUDE_DIR)

# Include paths search, renderer
FIND_PATH(CEGUI_EXTRA_INCLUDE_DIR OgreCEGUIRenderer.h ${CEGUI_INC_SEARCH_PATH})

IF(NOT CEGUI_EXTRA_INCLUDE_DIR)
   MESSAGE("WARNING: OgreCEGUIRenderer.h not found under ${CEGUI_INC_SEARCH_PATH}")
   SET(CEGUI_ALL_FOUND 0)
ENDIF(NOT CEGUI_EXTRA_INCLUDE_DIR)

# Cegui ogre renderer library
# Target compiler specific, as MSVC holds Debug and release separate
IF(MSVC)
   # Cegui library
   FIND_LIBRARY(CEGUI_CEGUI_LIB_RELEASE NAME ${CEGUIBASE_LIBNAMES_REL} PATHS ${CEGUI_LIB_SEARCH_PATH})
   FIND_LIBRARY(CEGUI_CEGUI_LIB_DEBUG NAME ${CEGUIBASE_LIBNAMES_DEB} PATHS ${CEGUI_LIB_SEARCH_PATH})

   IF(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)
      SET(CEGUI_CEGUI_LIB optimized ${CEGUI_CEGUI_LIB_RELEASE} debug ${CEGUI_CEGUI_LIB_DEBUG})
   ELSE(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)
      MESSAGE("WARNING: CEGUI library CEGUIBase not found under ${CEGUI_LIB_SEARCH_PATH}")
      SET(CEGUI_ALL_FOUND 0)
   ENDIF(CEGUI_CEGUI_LIB_DEBUG AND CEGUI_CEGUI_LIB_RELEASE)

   FIND_LIBRARY(CEGUI_OGRE_LIB_RELEASE ${CEGUI_LIBNAMES_REL} PATHS ${CEGUI_LIB_SEARCH_PATH})
   FIND_LIBRARY(CEGUI_OGRE_LIB_DEBUG ${CEGUI_LIBNAMES_DEB} PATHS ${CEGUI_LIB_SEARCH_PATH})

   IF(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
      SET(CEGUI_OGRE_LIB optimized ${CEGUI_OGRE_LIB_RELEASE} debug ${CEGUI_OGRE_LIB_DEBUG})
   ELSE(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
      MESSAGE("WARNING: CEGUI OGRE library CEGUIOgreRenderer not found under ${CEGUI_LIB_SEARCH_PATH}")
      SET(CEGUI_ALL_FOUND 0)
   ENDIF(CEGUI_OGRE_LIB_DEBUG AND CEGUI_OGRE_LIB_RELEASE)
ELSE(MSVC)
   # Cegui library
   FIND_LIBRARY(CEGUI_CEGUI_LIB NAME ${CEGUIBASE_LIBNAMES} PATHS ${CEGUI_LIB_SEARCH_PATH})

   IF(NOT CEGUI_CEGUI_LIB)
      MESSAGE("WARNING: CEGUI library CEGUIBase not found under ${CEGUI_LIB_SEARCH_PATH}")
      SET(CEGUI_ALL_FOUND 0)
   ENDIF(NOT CEGUI_CEGUI_LIB)


   FIND_LIBRARY(CEGUI_OGRE_LIB ${CEGUI_LIBNAMES} PATHS ${CEGUI_LIB_SEARCH_PATH})

   IF(NOT CEGUI_OGRE_LIB)
      MESSAGE("WARNING: CEGUI OGRE library CEGUIOgreRenderer not found under ${CEGUI_LIB_SEARCH_PATH}")
      SET(CEGUI_ALL_FOUND 0)
   ENDIF(NOT CEGUI_OGRE_LIB)
ENDIF(MSVC)

# Extra paths for include of CEGUI (for CEGUIOgreRenderer.h)
IF(CEGUI_EXTRA_INCLUDE_DIR)
    SET(CEGUI_INCLUDE_DIR ${CEGUI_EXTRA_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR})
ENDIF(CEGUI_EXTRA_INCLUDE_DIR)

SET(CEGUI_LIBRARIES ${CEGUI_CEGUI_LIB} ${CEGUI_OGRE_LIB})

IF(CEGUI_INCLUDE_DIR AND CEGUI_CEGUI_LIB AND CEGUI_OGRE_LIB AND CEGUI_ALL_FOUND)
    SET(CEGUI_FOUND "Yes")
ENDIF(CEGUI_INCLUDE_DIR AND CEGUI_CEGUI_LIB AND CEGUI_OGRE_LIB AND CEGUI_ALL_FOUND)

MARK_AS_ADVANCED(CEGUI_INCLUDE_DIR)
MARK_AS_ADVANCED(CEGUI_LIBRARIES)
MARK_AS_ADVANCED(CEGUI_LIBNAMES)
MARK_AS_ADVANCED(CEGUI_EXTRA_INCLUDE_DIR)
MARK_AS_ADVANCED(CEGUI_CEGUI_LIB)
MARK_AS_ADVANCED(CEGUI_OGRE_LIB)
 
 
 
 
 
 
 
 
 
 
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 (Boost_INCLUDE_DIR C:/OgreSDK_vc9_v1-7-2/boost_1_44)
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
	include_directories(${Boost_INCLUDE_DIR})
	add_definitions(-DBOOST_ALL_NO_LIB)
	set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
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)
I've also added a few env vars : CEGUI_HOME and CEGUI_EXTRA_INCLUDE_DIR
Delete cache, configure, generate, build and... still no luck.
I'm getting the same error as before
Closinc VC9, deleting my build dir, re-running CMake and I got a warning during CMake configure :
Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
WARNING: OgreCEGUIRenderer.h not found under C:\OgreSDK_vc10_v1-7-2/include;C:\OgreSDK_vc10_v1-7-2/include/CEGUI;C:\OgreSDK_vc10_v1-7-2/samples/include;C:\CEGUI-SDK-0.7.5-vc9/include;C:\CEGUI-SDK-0.7.5-vc9/include/CEGUI;C:\CEGUI-SDK-0.7.5-vc9/cegui/include;C:\CEGUI-SDK-0.7.5-vc9\cegui;C:\CEGUI-SDK-0.7.5-vc9\cegui/include
Looking for OGRE...
OGRE_PREFIX_WATCH changed.
Found Ogre Cthugha (1.7.2)
Found OGRE: optimized;C:/OgreSDK_vc10_v1-7-2/lib/release/OgreMain.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/debug/OgreMain_d.lib
Looking for OGRE_Paging...
Found OGRE_Paging: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgrePaging.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgrePaging_d.lib
Looking for OGRE_Terrain...
Found OGRE_Terrain: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreTerrain.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreTerrain_d.lib
Looking for OGRE_Property...
Found OGRE_Property: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreProperty.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreProperty_d.lib
Looking for OGRE_RTShaderSystem...
Found OGRE_RTShaderSystem: optimized;C:/OgreSDK_vc10_v1-7-2/lib/Release/OgreRTShaderSystem.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/Debug/OgreRTShaderSystem_d.lib
Looking for OIS...
OIS_PREFIX_PATH changed.
Found OIS: optimized;C:/OgreSDK_vc10_v1-7-2/lib/release/OIS.lib;debug;C:/OgreSDK_vc10_v1-7-2/lib/debug/OIS_d.lib
Configuring done
I suppose I got a wrong version of CEGUI ?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

If you are not sure why you need it, then you don't need it.
There is no trace of CEGUI in the CMake script from the Ogre wiki, so I really don't see where you could have gotten it unless you are still using that unsolicited CMake script with CEGUI in it..

But, if you really want to use CEGUI, a proper find cegui script is what you need.

Now:
Do you want to use CEGUI or not?

If you don't, use the CMake script from our wiki. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Looking at the output you posted just now, it all looks fine. :)
Just generate and build.

Do not worry about CEGUI at all.

And yes: IF YOU NEED CEGUI, then you need to build it from source. :wink:

But if you don't, then just generate and build.
There's no errors in that CMake log.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Okay, I've started to follow your instructions :
I created the file Find_CEGUI.cmake in the CMake dir of my OGRE_HOME but CMake complained that it didn't find it :
CMake Error at CMakeLists.txt:28 (find_package):
Could not find module FindCEGUI.cmake or a configuration file for package
CEGUI.

Adjust CMAKE_MODULE_PATH to find FindCEGUI.cmake or set CEGUI_DIR to the
directory containing a CMake configuration file for CEGUI. The file will
have one of the following names:

CEGUIConfig.cmake
cegui-config.cmake



WARNING: OgreCEGUIRenderer.h not found under C:\OgreSDK_vc9_v1-7-2/include;C:\OgreSDK_vc9_v1-7-2/include/CEGUI;C:\OgreSDK_vc9_v1-7-2/samples/include;C:\CEGUI-SDK-0.7.5-vc9/include;C:\CEGUI-SDK-0.7.5-vc9/include/CEGUI;C:\CEGUI-SDK-0.7.5-vc9/cegui/include;C:\CEGUI-SDK-0.7.5-vc9\cegui;C:\CEGUI-SDK-0.7.5-vc9\cegui/include
So I set CMAKE_MODULE_PATH to %OGRE_HOME%/CMake but still no luck
Then I also renamed Find_CEGUI.cmake to FindCEGUI.cmake but nothing did it : I always got the same error.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

jacmoe wrote:If you are not sure why you need it, then you don't need it.
Indeed I'm pretty sure I don't
jacmoe wrote: There is no trace of CEGUI in the CMake script from the Ogre wiki, so I really don't see where you could have gotten it unless you are still using that unsolicited CMake script with CEGUI in it..
That's really weird : I'm using the CMake script from your wiki... I suppose this reference could be somewhere in a dependency or an outdated version of something... This is definately weird.
jacmoe wrote:
But, if you really want to use CEGUI, a proper find cegui script is what you need.

Now:
Do you want to use CEGUI or not?
Nope :)

Thanks
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

Still not working :
1>------ Build started: Project: OgreApp, Configuration: Debug Win32 ------
1>Performing Pre-Build Event...
1>Compiling...
1>acollection.cpp
1>..\clean_ogre_cmake_project\acollection.cpp(22) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(24) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>..\clean_ogre_cmake_project\acollection.cpp(37) : warning C4244: 'return' : conversion from 'unsigned int' to 'float', possible loss of data
1>..\clean_ogre_cmake_project\acollection.cpp(53) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(59) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(69) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(75) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(83) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\acollection.cpp(95) : warning C4018: '<' : signed/unsigned mismatch
1>enginemaths.cpp
1>codetrimmer.cpp
1>light.cpp
1>pointLight.cpp
1>declaredfunction.cpp
1>..\clean_ogre_cmake_project\declaredfunction.cpp(24) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\declaredfunction.cpp(43) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\declaredfunction.cpp(51) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\declaredfunction.cpp(60) : warning C4018: '<' : signed/unsigned mismatch
1>animstate.cpp
1>error.cpp
1>astring.cpp
1>afloat.cpp
1>abool.cpp
1>accessible.cpp
1>vector.cpp
1>variable.cpp
1>TutorialApplication.cpp
1>terrain.cpp
1>pivot.cpp
1>physics.cpp
1>parser.cpp
1>mouse.cpp
1>Generating Code...
1>Compiling...
1>mesh.cpp
1>localset.cpp
1>..\clean_ogre_cmake_project\localset.cpp(28) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\localset.cpp(41) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\localset.cpp(57) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\localset.cpp(65) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\localset.cpp(74) : warning C4018: '<' : signed/unsigned mismatch
1>..\clean_ogre_cmake_project\localset.cpp(83) : warning C4018: '<' : signed/unsigned mismatch
1>keyboard.cpp
1>functions.cpp
1>function.cpp
1>freeview.cpp
1>collection.cpp
1>camera.cpp
1>BaseApplication.cpp
1>arbitrator.cpp
1>abstractentity.cpp
1>Generating Code...
1>c:\clean_ogre_cmake_project\baseapplication.cpp(235) : warning C4715: 'OgreManager::setupPlugins' : not all control paths return a value
1>c:\clean_ogre_cmake_project\keyboard.cpp(174) : warning C4715: 'Keyboard::stringToScancode' : not all control paths return a value
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'CEGUIBase_d.lib'
1>Build log was saved at "file://c:\clean_ogre_cmake_project_build\OgreApp.dir\Debug\BuildLog.htm"
1>OgreApp - 1 error(s), 21 warning(s)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Are you messing with me? :)
Did you configure and generate a completely new project?
Using the new CMake script?

Visual Studio doesn't add that CEGUI library by itself.

Double-check your setup.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Linker error during Windows CMake build

Post by jacmoe »

Could you post the CMake script you're using now?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

:) I'm going to create a new project using clean_ogre_cmake_project and keep you informed.

Thanks a milion !
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Linker error during Windows CMake build

Post by guillaumequest »

It works ! Thanks and have a good day :)
Post Reply