Tutorial 1.11.1 - how to use components added by OGREConfig.cmake?? Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
rh_auto8
Gnoblar
Posts: 8
Joined: Sat Jul 07, 2018 8:16 pm

Tutorial 1.11.1 - how to use components added by OGREConfig.cmake??

Post by rh_auto8 » Tue Jul 10, 2018 10:19 pm

Ogre Version: 1.11.1
Operating System: Windows 8.1

I've started the tutorial for 1.11.1. The tutorial says to get going all I have to do is add the following to my CMakeLists (which I've done):

Code: Select all

#...all you need is to add the following lines to your project

# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS Bites RTShaderSystem)
# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})
Great, it seems to find it all:

Code: Select all

Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/HostX86/x64/cl.exe", "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/HostX86/x64/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.8/msvc2015_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.8/msvc2015_64/bin/qmake.exe".
Ogre SDK is at = C:\Ogre3D\SDK\1_11_1\MSVC
Ogre CMakes at = C:\Ogre3D\SDK\1_11_1\MSVC\CMake
Found OGRE
  static     : OFF
  components : Bites;HLMS;MeshLodGenerator;Overlay;Paging;Property;RTShaderSystem;Terrain;Volume
  plugins    : Plugin_BSPSceneManager;Plugin_OctreeSceneManager;Plugin_PCZSceneManager;Plugin_ParticleFX;RenderSystem_GL;RenderSystem_GL3Plus;RenderSystem_Direct3D9;RenderSystem_Direct3D11
  media      : C:/Ogre3D/SDK/1_11_1/MSVC/Media
Configuring done
Generating done
CMake Project was parsed successfully.
But... how do I now use the added components in my application? I tried adding:

Code: Select all

 #include <Ogre.h> 
but it isnt found. Should that be what I'm doing? The tutorial doesnt say what I should include, it just tells you to start using

Code: Select all

OgreBites::ApplicationContext
Any help is greatly appreciated!!! Thanks!
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 917
Joined: Sun Mar 30, 2014 2:51 pm
x 205
Contact:

Re: Tutorial 1.11.1 - how to use components added by OGREConfig.cmake??

Post by paroj » Tue Jul 10, 2018 11:42 pm

ah yes, the most important line is actually missing from the tutorial as I deemed it to be complusory. See target_link_libraries here:
https://github.com/OGRECave/ogre/blob/m ... ts.txt#L13
1 x

rh_auto8
Gnoblar
Posts: 8
Joined: Sat Jul 07, 2018 8:16 pm

Re: Tutorial 1.11.1 - how to use components added by OGREConfig.cmake??

Post by rh_auto8 » Wed Jul 11, 2018 12:55 pm

Thanks again for your help Paroj. I was speaking to my colleague today who is more familiar with CMake (I'm a CMake Noobie) and he suggested that I had missed that also. Good to see a link that I can copy from, I'll try that when I get home this evening.
0 x

rh_auto8
Gnoblar
Posts: 8
Joined: Sat Jul 07, 2018 8:16 pm

Re: Tutorial 1.11.1 - how to use components added by OGREConfig.cmake??

Post by rh_auto8 » Wed Jul 11, 2018 10:30 pm

Paroj has suggested the right fix (as expected), I'll mark it as resolved.

In case anyone else runs into the issue, here was my final CMakeLists file:

Code: Select all


cmake_minimum_required(VERSION 3.12)

set(OGRE_DIR $ENV{OGRE_HOME}\\CMake)
message("Ogre SDK is at = $ENV{OGRE_HOME}")
message("Ogre CMakes at = ${OGRE_DIR}")

# specify which version and components you need
find_package(OGRE 1.11.1 REQUIRED COMPONENTS Bites RTShaderSystem)

# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})

add_executable(Game main.cpp)
target_link_libraries(Game ${OGRE_LIBRARIES})

which let me use the header files!

Thanks again paroj!
0 x

ZiedBargaoui
Gnoblar
Posts: 2
Joined: Tue Nov 06, 2018 11:44 pm

Re: Tutorial 1.11.1 - how to use components added by OGREConfig.cmake??

Post by ZiedBargaoui » Sat Nov 10, 2018 1:40 pm

Hello everybody,

I am having the same trouble since 2 weeks!

I have Linux Mint and Ogre 1.11.3 and I have always this:

Code: Select all

13:33:06 **** Incremental Build of configuration Debug for project myogre ****
make all 
Building file: ../src/myogre.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/include/OGRE/ -I/home/zied/ogre/ogre-1.11.3/build/include/ -I/usr/local/include/OGRE/RTShaderSystem/ -I/usr/local/include/OGRE/Bites/ -I/usr/local/include/OGRE/Overlay/ -I/usr/include/SDL2 -O0 -g3 -Wall -std=c++11 `pkg-config --libs --cflags OGRE` -MMD -MP -MF"src/myogre.d" -MT"src/myogre.o" -o "src/myogre.o" "../src/myogre.cpp"
/tmp/ccSnviVS.o: In function `main':
/home/zied/workspace_2017/myogre/Debug/../src/myogre.cpp:6: undefined reference to `OgreBites::ApplicationContext::ApplicationContext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
src/subdir.mk:18: recipe for target 'src/myogre.o' failed
/home/zied/workspace_2017/myogre/Debug/../src/myogre.cpp:6: undefined reference to `OgreBites::ApplicationContext::~ApplicationContext()'
collect2: error: ld returned 1 exit status
make: *** [src/myogre.o] Error 1

13:33:08 Build Failed. 4 errors, 0 warnings. (took 2s.126ms)
I don't know how to use the Cmake file! could you please show me the structure of your project?
0 x

Post Reply