How to link to Irrlicht using CMake?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AzP
Posts: 16
Joined: Fri Jun 09, 2006 8:47 pm
Location: Stockholm, Sweden

How to link to Irrlicht using CMake?

Post by AzP »

I am currently trying to port my project to CMake, so it will be easier to use on different platforms, and also to have some sort of "official" build system instead of my old hand written Makefiles.

The problem that I have come to, after many hours, is that I can't seem to figure out how to link to the Irrlicht library. Any pointers?

One of my current CMakeLists.txt looks like the following:

Code: Select all

find_package( SDL REQUIRED
	SDL_net REQUIRED
	SDL_sound REQUIRED
	OpenGL REQUIRED
	PNG REQUIRED
	JPEG REQUIRED
	)

if ( NOT SDL_FOUND )
	message ( SEND_ERROR "SDL not found!" )
endif ( NOT SDL_FOUND )

if ( NOT SDLNET_FOUND )
	message ( STATUS "SDLNET not found!" )
endif ( NOT SDLNET_FOUND )

if ( NOT SDL_SOUND_FOUND )
	message ( STATUS "SDL_SOUND not found!" )
endif ( NOT SDL_SOUND_FOUND )

include_directories(include/ ${SDL_INCLUDE_DIR} /usr/include/irrlicht/)

link_libraries(
	${SDL_LIBRARY}
	${SDLNET_LIBRARY}
	${SDL_SOUND_LIBRARIES}
	${OPENGL_LIBRARY}
	${PNG_LIBRARY}
	${JPEG_LIBRARY}
	SDLmain
	Irrlicht
	)

set(sourcefiles
	ammo.cpp
	audio.cpp
        .
        .
	shot.cpp
	)

add_executable(subspacebattle ${sourcefiles})
install_programs(/bin subspacebattle)
and the errors are lots of linking problems (there are a couple of hundred lines):

Code: Select all

/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0xbf): undefined reference to `XUnmapWindow'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0xc8): undefined reference to `XAllocSizeHints'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0x106): undefined reference to `XSetWMNormalHints'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0x10e): undefined reference to `XFree'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0x121): undefined reference to `XMapWindow'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::setResizeAble(bool)':
(.text+0x156): undefined reference to `XSetWMNormalHints'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../lib64/libIrrlicht.a(CIrrDeviceLinux.o): In function `irr::CIrrDeviceLinux::present(irr::video::IImage*, int, irr::core::rect<int>*)':
(.text+0x371): undefined reference to `XPutImage'
.
.

Has anybody written a modulefile like "FindIrrlicht.cmake"? That would be great, since the person could send it and get it in their main releases. I saw something about Ogre having pre-written module files.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Irrlicht depends on some other libraries which are simply missing in your list. Check the Makefiles for the examples to get those names.
Post Reply