Compiling Ogre 2.1 + SDL2 missing dependency

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Compiling Ogre 2.1 + SDL2 missing dependency

Post by dark_sylinc »

This gets asked a lot, so I figgured to make it sticky.

The instructions are the same as in 1.x

The only addition is that if you want the samples (which you probably do) you need to turn on OGRE_BUILD_SAMPLES2 (the old OGRE_BUILD_SAMPLES contains the old samples which don't work)
If you're on windows you'll have to setup SDL2 paths manually on CMake so these samples can work.
Download and compile SDL2.

For example my setup is:

Code: Select all

SDL2MAIN_LIBRARY G:\SDK\SDL2\VisualC\Win32\Debug\SDL2.lib
SDL2_INCLUDE_DIR G:\SDK\SDL2\include
SDL2_LIBRARY G:\SDK\SDL2\VisualC\Win32\Debug\SDL2.lib
"G:\SDK\SDL2\" is where I unpacked the SDL2 source code and compiled it (solution files for compiling with Visual Studio are in G:\SDK\SDL2\VisualC).

Do not use Boost. It's pointless and may cause trouble. Ideally in the future the option to turn it on will be completely removed.

Also don't play with the CMake options too much. First get it running with the default settings. Once you got it, you can start tweaking it (just in case you bump into a broken one or an invalid combination, etc)
hydexon
Gremlin
Posts: 164
Joined: Sun Apr 14, 2013 8:51 pm
x 10

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Post by hydexon »

lmao. indeed it's very asked, i figured myself when you posted at the first glance of the SDL2 libraries in Windows..., idk why is so difficult...
Enes
Gnoblar
Posts: 1
Joined: Wed May 18, 2016 8:05 am

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Post by Enes »

NOTE: This is only relevant to Visual Studio 2015. I am using community edition.

Since this is the first relevant thread i looked in to while compiling ogre 2.1 and it's dependencies i thought i could drop a note here:

There is also a problem compiling sdl2 branch from ogredeps bitbucket repo with VS2015,
1.Freeimage
Freeimage defines snprintf in 4 files* which is already defined in vc++ in vs2015. These either need to be removed or wrapped inside conditionals with msvc version. Like this:

Code: Select all

#if _MSC_VER < 1900
   #define snprintf _snprintf
#endif
*:changes are need to be made in these files (hint: searc files for "#define snprintf" ):
./LibRawLite/dcraw/dcraw.c
./LibRawLite/internal/defines.h
./LibTIFF4/tif_config.h
./LibTIFF4/tif_config.vc.h

2.SDL2
And then SDL2 throws some external symbol not found errors at link time for debug builds.
I am sure there is a better way to this but i solved it by adding the lines below in ogredeps_repo_dir\src\SDL2\CMakeLists.txt

Code: Select all

if(MSVC)
    list(APPEND EXTRA_LIBS vcruntimed ucrtd msvcrtd)
endif()
At around line 1250 in if(SDL_SHARED) block right before

Code: Select all

set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
lines.
User avatar
bvanevery
Goblin
Posts: 218
Joined: Wed Feb 28, 2007 4:54 am
Location: Asheville, NC
x 7

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Post by bvanevery »

This sticky has really muddied advice. It points out some problems, but some have been patched in the ogredeps "default" branch. For instance, the FreeImage snprintf problem was fixed. Other problems, were fixed in the ogredeps "sdl2" branch by moving to SDL2 2.0.4. But not all solutions are shared in the branches. I'm rather confused at this point why there are 2 branches. Neither one actually builds with VS2015 on Windows 10, although combining the changes would probably work.

I've verified that the snprintf problem exists even in FreeImage 3.17.0, built from straight upstream sources. It includes Visual Studio 2013 .sln files. I ran them under VS2015, which updated them to that version.

I've found a magic incantation that works for me. SDL2 is implemented as a subrepo in ogredeps. Conseqently the following works:
- clone the ogredeps repo https://bitbucket.org/cabalistic/ogredeps
- open a command prompt, go to the \src\SDL2 subdirectory
- type "hg update release-2.0.4"

Then the build works fine.
User avatar
bvanevery
Goblin
Posts: 218
Joined: Wed Feb 28, 2007 4:54 am
Location: Asheville, NC
x 7

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Post by bvanevery »

All of the above issues have now been addressed in ogredeps. In particular, SDL2 was bumped to to stock 2.0.4, no modifications. This solves problems. Suggest unstickying this thread, as Ogre doesn't have a SDL2 build problem anymore, nor will it if someone builds stock 2.0.4 on their own.

Someone may want to know about the FreeImage problem, as it exists in stock FreeImage sources. The ogredeps sources have been patched. However this has nothing to do with Ogre 2.1 and SDL2; technically it's off-topic. Someone could sticky a new thread about FreeImage if they really think it comes up much.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Post by spacegaier »

/* "Unstickied" since as bvanevery mentioned, I bumped SDL to 2.0.4 in the dependency repo and all other issues should be gone as well. */
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Post Reply