ogre-next icon indicating copy to clipboard operation
ogre-next copied to clipboard

GraphicsSystem.h:17:21: fatal error: SDL.h: No such file or directory

Open KammutierSpule opened this issue 8 years ago • 5 comments

This is related to 2-1 banch: I am trying to build the "EmptyProject". I am able to build Ogre project and install it. It builds the examples etc. I am able to run the Cmake in the "EmptyProject" to generate the makefiles.

In the cmake-gui I can see the SDL2_DIR pointing to "/usr/lib/x86_64-linux-gnu/cmake/SDL2"

But it fails to build. It looks like the SDL is detected but the include is not correctly added to include paths of the project.

I am using latest Linux Mint (Ubuntu based).

KammutierSpule avatar Oct 10 '17 08:10 KammutierSpule

There is no SDL2_DIR path. There should be SDL2MAIN_LIBRARY, SDL2_INCLUDE_DIR and SDL2_LIBRARY.

I suspect Mint is bundling a FindSDL2.cmake that is conflicting with ours, and the script is picking up the system one.

Do you have the following file...? EmptyProject/Dependencies/Ogre/CMake/Packages/FindSDL2.cmake

darksylinc avatar Oct 10 '17 19:10 darksylinc

I am trying to use OGRE installed in the system. So I setup the path in cmake-gui for OGRE and cmake from the "Emptyproject" runs successfully. So I have one /usr/local/lib/OGRE/cmake/FindSDL2.cmake I didn't found any other FindSDL2.cmake There is only one: /usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake

KammutierSpule avatar Oct 11 '17 08:10 KammutierSpule

As the documentations says, the script expects OGRE to be at Dependencies/Ogre (can be a shared folder) and built binaries at Dependencies/Ogre/build/Debug (or Release/RelWithDebug/etc).

You can avoid that but you'll have to set OGRE_SOURCE, OGRE_BINARIES & OGRE_DEPENDENCIES before running CMake, so that the script sees the FindSDL2.cmake included with Ogre instead of you own. (Beware your CMake build has already picked up a version of FindSDL2.cmake so it's goint to stick with it, it's better to clean the cmake build folder of EmptyProject)

In Ogre 2.1 we're trying to move away from OGRE being "installed" in the system as it causes more problems than it solves (Ogre is often customized, ABI breakage is very common in C++, unlike C libs).

darksylinc avatar Oct 11 '17 15:10 darksylinc

In Ogre 2.1 we're trying to move away from OGRE being "installed" in the system as it causes more problems than it solves

note that this does not apply to 1.10, where we actually pay attention not to break the API/ ABI. Unfortunately this can not avoided with the current codebase. The goal is to allow 1.x to be upgraded just as any other library, but with 1.10 we are still in the process of hiding the private API.

paroj avatar Oct 12 '17 22:10 paroj

I was also having trouble finding SDL2 due to using non-conventional dependency paths. My ogre-next is a git submodule located at my-project/ogre-next (instead of at my-project/Dependencies/Ogre). Likewise, my ogre-next-deps is a git submodule at my-project/ogre-next-deps.

I had to change a line in EmptyProject/CMake/Dependencies/OGRE.cmake from this...

set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/Ogre/CMake/Packages" )

to this...

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/Ogre/CMake/Packages")
list(APPEND CMAKE_MODULE_PATH "${OGRE_SOURCE}/CMake/Packages")

I also had to change the line...

set( CMAKE_PREFIX_PATH "${OGRE_SOURCE}/Dependencies ${CMAKE_PREFIX_PATH}" )

to this...

list(APPEND CMAKE_PREFIX_PATH "${OGRE_SOURCE}/Dependencies")
list(APPEND CMAKE_PREFIX_PATH "${OGRE_DEPENDENCIES_DIR}")

Of course, I make sure to pass these args to the CMake configure command:

-DOGRE_DEPENDENCIES_DIR:PATH:STRING=c:/Projects/my-project/ogre-next-deps/build/ogredeps -DOGRE_SOURCE:PATH:STRING=c:/Projects/my-project/ogre-next

The changes I listed above fixed it for me. I can now find SDL2 just fine, which gives me this output...

...
[cmake] -- SDL2_INCLUDE_DIR: C:/Projects/my-project/ogre-next-deps/build/ogredeps/include/SDL2
[cmake] -- SDL2_LIBRARY_TEMP: winmm;imm32;version;msimg32;C:/Projects/my-project/ogre-next-deps/build/ogredeps/lib/SDL2main.lib;C:/Projects/my-project/ogre-next-deps/build/ogredeps/lib/SDL2.lib
[cmake] -- Found SDL2
...

Note that my CMake version is 3.17.3.

MBetters avatar Nov 30 '20 18:11 MBetters