Compiling Ogre 2.1 + SDL2 missing dependency

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)

Compiling Ogre 2.1 + SDL2 missing dependency

Postby dark_sylinc » Sat Nov 14, 2015 2:23 am

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_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)
User avatar
OGRE Team Member
OGRE Team Member
Posts: 3080
Kudos: 469
Joined: 21 Jul 2007
Location: Buenos Aires, Argentina

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Postby hydexon » Sat Nov 14, 2015 3:41 am

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...
Posts: 162
Kudos: 9
Joined: 14 Apr 2013

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Postby Enes » Wed May 18, 2016 8:18 am

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,
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

*:changes are need to be made in these files (hint: searc files for "#define snprintf" ):

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
    list(APPEND EXTRA_LIBS vcruntimed ucrtd msvcrtd)

At around line 1250 in if(SDL_SHARED) block right before
Code: Select all
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})

Posts: 1
Kudos: 0
Joined: 18 May 2016

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Postby bvanevery » Sat Jul 09, 2016 12:19 am

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
- open a command prompt, go to the \src\SDL2 subdirectory
- type "hg update release-2.0.4"

Then the build works fine.

For this message the author bvanevery has received kudos
User avatar
Posts: 218
Kudos: 6
Joined: 28 Feb 2007
Location: Asheville, NC

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Postby bvanevery » Thu Jul 14, 2016 9:58 pm

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
Posts: 218
Kudos: 6
Joined: 28 Feb 2007
Location: Asheville, NC

Re: Compiling Ogre 2.1 + SDL2 missing dependency

Postby spacegaier » Thu Jul 14, 2016 10:07 pm

/* "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...
User avatar
OGRE Team Member
OGRE Team Member
Posts: 4291
Kudos: 126
Joined: 04 Feb 2008
Location: Germany

Return to Ogre 2.0+

Who is online

Users browsing this forum: No registered users and 2 guests