Page 1 of 1

How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Wed Feb 06, 2019 3:43 am
by CollegeDropout
Ogre Version: 1.11.5
Operating System: Windows 10
Render System: DirectX?

I tried doing the Setting Up an OGRE Project tutorial, and it says nothing about adding any dependencies. I assumed CMake would handle that or something, since the tutorial only mentions putting some lines into your CMakeLists.txt file before it gets into the actual code for the test application. When I went to compile, I got all of these errors telling me it can't open any of the includes, so CMake definitely didn't do anything to add dependencies. I didn't get any errors with my CMakeLists.txt, so I assumed there was nothing wrong with that. Unless I'm wrong, this is telling me that CMake doesn't do anything related to dependencies so I just manually added every folder inside of the sdk folder's "includes" directory (and the subdirectories). This made the header errors go away, but then I got all of these linker errors like these:

Code: Select all

Error	LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall Ogre::VectorBase<3,float>::VectorBase<3,float>(float,float,float)" (__imp_??0?$VectorBase@$02M@Ogre@@QAE@MMM@Z) referenced in function "public: __thiscall Ogre::Vector<3,float>::Vector<3,float>(float,float,float)" (??0?$Vector@$02M@Ogre@@QAE@MMM@Z)	ogreproj	C:\coding\OgrePlayground\ogreproj\ogreproj.obj	1	
I tried looking this problem up, but there is a disturbing lack of anyone else having this problem, and I know people are using Ogre 1.11.5 right now with no issues so I know setting Ogre up isn't supposed to be this painful. It feels like the answer is just right in front of my face, but I can't see it. What is with the dependencies with Ogre 11? I used a really old version of ogre a while back, and all I had to do was just add a couple of include folders and libraries to my project's settings and that was that. I'm not saying it was better that way or anything, but the simplicity that CMake promises just makes troubleshooting harder for me to follow when something goes wrong. For example: I tried generating with Visual Studio 15 2017 x64 once and ran into problems with that until I realized using the regular Visual Studio 15 generator was the one that worked. I'm chalking that one up to just not knowing about CMake very well, but this new problem is perplexing since I know I followed the tutorials to the letter, and CMake hasn't given any errors or anything. I feel like I'm just doing this all backwards but I'm trying to follow the documentation as closely as I can. From the way it's written, it feels like setting this up should be a lot smoother and simpler than it has been for me.

If this problem is because I messed up something in my CMakeLists.txt, here it is just in case:

Code: Select all

cmake_minimum_required (VERSION 2.8)
project (ogreproj)

add_executable(ogreproj ogreproj.cpp)

set(OGRE_DIR C:/coding/OgrePlayground/deps/ogre3d/builds/ogre-1.11.5/sdk/CMake)

# 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})

Re: How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Wed Feb 06, 2019 12:33 pm
by paroj
if you are using the prebuild sdk, you must build your project in release mode (CMAKE_BUILD_TYPE) as it only provides release libraries.

Re: How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Wed Feb 06, 2019 11:31 pm
by CollegeDropout
Okay, I figured out this problem. I have another problem now, but this one is solved. Here is how I fixed it:
paroj wrote: Wed Feb 06, 2019 12:33 pm if you are using the prebuild sdk, you must build your project in release mode (CMAKE_BUILD_TYPE) as it only provides release libraries.
I'm building the sdk from source. Building my project in release mode didn't work, but what you said did lead me to investigating some things about cmake and visual studio. Turns out I might have been doing something seriously wrong by making my project in visual studio instead of using cmake to generate one. It sounds stupid of me to do in retrospect, but something about how the ogre project tutorial was written lead me to believe CMakeLists.txt was supposed to be added to an existing project. I updated my CMakeLists.txt a bit and generated a project with that.

Unfortunately, this didn't fix my problem since it still didn't add any Ogre dependencies to the project. I was frustrated, but building my project with cmake gave me an idea: Using what I had just learned, I decided to generate a project for the tutorial applications in the Samples/tutorial folder and see if they would compile and run properly. If they did, I could just pick them apart and compare them with my project to see what I did differently (read: did wrong). I generate the projects, and they compile just fine! All the ogre include directories are in the project's settings for the tutorials. I tried to run the .exes after compiling them and they can't find any of ogre's .dlls even though I checked and they're in the sdk's bin folder. That wasn't part of my main issue so I didn't worry about that, but the fact that the tutorials could even compile at all while my own project couldn't tells me that my CMakeLists.txt is wrong.

So I investigated what was different between my CMakeLists.txt and theirs, and lo an behold there is an entire line that gives your project the includes which the online tutorials never tell you to add:

Code: Select all

target_link_libraries(YOURTARGETHERE ${OGRE_LIBRARIES})
In fact, it explicitly says that after the find_package() and the resource.cfg copy lines, that's all you would need to put into your CMakeLists.txt to get ogre to work:
These settings include all available components and third party libraries OGRE depends on (e.g. boost) - nothing more to do.
That clearly was not the case for me.

So I modified my CMakeLists.txt and generated a new project to be like so:

Code: Select all

cmake_minimum_required (VERSION 2.8)
project (ogreproject)


set(OGRE_DIR C:/coding/OgrePlayground/deps/ogre3d/builds/ogre-1.11.5/sdk/CMake)

# 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})

add_executable(ogreproj src/ogreproj.cpp)
target_link_libraries(ogreproj ${OGRE_LIBRARIES})
target_include_directories(ogreproj PUBLIC headers PUBLIC src)
And like magic, my project has all the includes I needed now! It finally compiles!

... Except now I have one more problem: You know back when I compiled the sample tutorial projects and, while they compiled, couldn't run because they couldn't find a bunch of Ogre .dlls? That's happening again, but for my project. Should I make a separate thread for that one, or just keep this one?

Re: How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Thu Feb 07, 2019 12:09 am
by paroj
CollegeDropout wrote: Wed Feb 06, 2019 11:31 pm So I investigated what was different between my CMakeLists.txt and theirs, and lo an behold there is an entire line that gives your project the includes which the online tutorials never tell you to add:

Code: Select all

target_link_libraries(YOURTARGETHERE ${OGRE_LIBRARIES})
In fact, it explicitly says that after the find_package() and the resource.cfg copy lines, that's all you would need to put into your CMakeLists.txt to get ogre to work:
These settings include all available components and third party libraries OGRE depends on (e.g. boost) - nothing more to do.
That clearly was not the case for me.
sorry, thats my bad. With 1.11 the CMake stuff got slightly simpler compared to 1.10:
https://ogrecave.github.io/ogre/api/1.10/setup.html

so I deleted those lines without updating the text..
CollegeDropout wrote: Wed Feb 06, 2019 11:31 pm ... Except now I have one more problem: You know back when I compiled the sample tutorial projects and, while they compiled, couldn't run because they couldn't find a bunch of Ogre .dlls? That's happening again, but for my project. Should I make a separate thread for that one, or just keep this one?
copy the resulting exe into sdk/bin and it should work. Alternatively change your PATH variable to include sdk/bin to run it from anywhere.

Re: How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Thu Feb 07, 2019 1:43 am
by CollegeDropout
paroj wrote: Thu Feb 07, 2019 12:09 am
CollegeDropout wrote: Wed Feb 06, 2019 11:31 pm So I investigated what was different between my CMakeLists.txt and theirs, and lo an behold there is an entire line that gives your project the includes which the online tutorials never tell you to add:

Code: Select all

target_link_libraries(YOURTARGETHERE ${OGRE_LIBRARIES})
In fact, it explicitly says that after the find_package() and the resource.cfg copy lines, that's all you would need to put into your CMakeLists.txt to get ogre to work:
These settings include all available components and third party libraries OGRE depends on (e.g. boost) - nothing more to do.
That clearly was not the case for me.
sorry, thats my bad. With 1.11 the CMake stuff got slightly simpler compared to 1.10:
https://ogrecave.github.io/ogre/api/1.10/setup.html

so I deleted those lines without updating the text..
CollegeDropout wrote: Wed Feb 06, 2019 11:31 pm ... Except now I have one more problem: You know back when I compiled the sample tutorial projects and, while they compiled, couldn't run because they couldn't find a bunch of Ogre .dlls? That's happening again, but for my project. Should I make a separate thread for that one, or just keep this one?
copy the resulting exe into sdk/bin and it should work. Alternatively change your PATH variable to include sdk/bin to run it from anywhere.
That did the trick, thank you so much! The project compiles and runs correctly now.

Re: How am I supposed to do dependencies for Ogre 1.11.5?

Posted: Thu Feb 07, 2019 12:08 pm
by paroj
updated the descriptions in master:
https://codedocs.xyz/OGRECave/ogre/setup.html