New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build problems on Mac OS X (10.9) #25

Closed
thomcc opened this Issue Oct 27, 2013 · 12 comments

Comments

Projects
None yet
3 participants
@thomcc

thomcc commented Oct 27, 2013

By default, I was unable to get Magnum to build on the most recent version of OS X (10.9, with fully updated Xcode). I suspect that the issues I experienced would be the same on other OS X versions.

Ultimately, I got it to compile, but there were two issues that should probably be fixed with the CMake files (I've never used CMake for anything other than building other peoples libraries myself, so forgive any inaccurate terminology).

  • First error: When using cmake to generate Makefiles (e.g. cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_SDL2APPLICATION=ON) it fails with the error Could NOT find OpenAL (missing: OPENAL_INCLUDE_DIR).
    This was fixable by adding the horrifically long -DOPENAL_INCLUDE_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenAL.framework/Headers. Presumably, MacOSX10.8.sdk would be needed on 10.8, and etc. I'm not sure how you can fix this, as it seems the code for finding OpenAL is built-in to CMake (or it's hidden somewhere deep within your project), but it already does the right thing for OpenGL, so... maybe that helps.
  • Second error: when makeing everything after generating the makefiles above, compilation fails due to being unable to find SDL_scancode.h in Sdl2Application.h, included from Sdl2Application.cpp. It might be worth noting that it had already succeeded in including SDL.h at this point.
    This was fixable by adding -DSDL2_INCLUDE_DIR=/Library/Frameworks/SDL2.framework/Headers/ when using CMake to generate the makefiles. Prior to this, it did find SDL2 at /Library/Frameworks/SDL2.framework, so I'm not sure what the difference was. This issue could come from the fact that I originally installed SDL2 by using the installer from their website, and not by building from source, or via my package manager, but since that's the recommended method of installing SDL2, it should probably be supported.

Anyway, as I mentioned, after fixing these problems I was successfully able to compile and install Magnum, but these seemed to be issues with your build process, so I figured that reporting an issue about it might streamline the process for other users.

@mosra

This comment has been minimized.

Show comment
Hide comment
@mosra

mosra Oct 27, 2013

Owner

Thank you very much for the detailed report. I actually don't have access to any machine with OS X, so I might not able to trace or fix the exact issue.

  • You are right, the OpenAL finding routine is part of CMake itself. However it seems that the OpenAL library you found is somehow part of XCode, which explains the horrifically long include path. The official FindOpenAL.cmake tries to find it in /Library/Frameworks, thus I assume there must be some standalone version of OpenAL which is not bundled with XCode.
  • With SDL, isn't it possible that you have SDL 1.2 installed too? It would explain the missing header (SDL_scancode.h is available only in SDL2, in SDL 1.2 it was named SDL_keysym.h) -- it seems that CMake mistakenly found the SDL 1.2 include dir, although it did found SDL2 library properly. Sadly CMake doesn't yet provide a well-tested finding routine for SDL2 in default installation, so I must ship my own (buggy) version with Magnum. Weirdly enough, the finding routine in modules/FindSDL2.cmake seems to be already checking for SDL_scancode.h presence, thus it should in theory work flawlessly.
Owner

mosra commented Oct 27, 2013

Thank you very much for the detailed report. I actually don't have access to any machine with OS X, so I might not able to trace or fix the exact issue.

  • You are right, the OpenAL finding routine is part of CMake itself. However it seems that the OpenAL library you found is somehow part of XCode, which explains the horrifically long include path. The official FindOpenAL.cmake tries to find it in /Library/Frameworks, thus I assume there must be some standalone version of OpenAL which is not bundled with XCode.
  • With SDL, isn't it possible that you have SDL 1.2 installed too? It would explain the missing header (SDL_scancode.h is available only in SDL2, in SDL 1.2 it was named SDL_keysym.h) -- it seems that CMake mistakenly found the SDL 1.2 include dir, although it did found SDL2 library properly. Sadly CMake doesn't yet provide a well-tested finding routine for SDL2 in default installation, so I must ship my own (buggy) version with Magnum. Weirdly enough, the finding routine in modules/FindSDL2.cmake seems to be already checking for SDL_scancode.h presence, thus it should in theory work flawlessly.
@thomcc

This comment has been minimized.

Show comment
Hide comment
@thomcc

thomcc Oct 27, 2013

There's a version of OpenAL that comes with Mac OS X in /System/Library/Frameworks (none in /Library/Frameworks, for me at least), however it doesn't include the headers. The only way to get the one with the headers as far as I can tell is to use the one in the SDK, and I guess these are located inside Xcode.app, for some reason.

And yes, I do have SDL 1.2 installed, and that's probably what it was trying to use. I just did some investigating and it seems that unless I manually override SDL2_INCLUDE_DIR, it settles on /Library/Frameworks/SDL.framework/Headers, which is the SDL 1.2 header directory (it should be /Library/Frameworks/SDL2.framework/Headers). It does find SDL2_LIBRARY correctly, as /Library/Frameworks/SDL2.framework, so maybe something involving just the include path? Not sure if that helps you, but at least its clear what's happening.

thomcc commented Oct 27, 2013

There's a version of OpenAL that comes with Mac OS X in /System/Library/Frameworks (none in /Library/Frameworks, for me at least), however it doesn't include the headers. The only way to get the one with the headers as far as I can tell is to use the one in the SDK, and I guess these are located inside Xcode.app, for some reason.

And yes, I do have SDL 1.2 installed, and that's probably what it was trying to use. I just did some investigating and it seems that unless I manually override SDL2_INCLUDE_DIR, it settles on /Library/Frameworks/SDL.framework/Headers, which is the SDL 1.2 header directory (it should be /Library/Frameworks/SDL2.framework/Headers). It does find SDL2_LIBRARY correctly, as /Library/Frameworks/SDL2.framework, so maybe something involving just the include path? Not sure if that helps you, but at least its clear what's happening.

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc Dec 25, 2013

I have built the library to attempt to reproduce your issue, there were no issues on my end
I am using osx 10.9
cmake version 2.8.10.2 "darwin ports version"
clang 5.0 5000.2.79 llvm 3.3. svn

I installed the SDL2 framework to /Library/Frameworks/

I am going try installing SDL1.2 and see the result.

ArEnSc commented Dec 25, 2013

I have built the library to attempt to reproduce your issue, there were no issues on my end
I am using osx 10.9
cmake version 2.8.10.2 "darwin ports version"
clang 5.0 5000.2.79 llvm 3.3. svn

I installed the SDL2 framework to /Library/Frameworks/

I am going try installing SDL1.2 and see the result.

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc Dec 25, 2013

-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Corrade: /usr/lib/libCorradeUtility.dylib
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- LIB_SUFFIX variable is not defined. It will be autodetected now.
-- You can set it manually with -DLIB_SUFFIX= (64 for example)
-- LIB_SUFFIX autodetected as '', libraries will be installed into /Developer/libs/lib
-- Could NOT find SDL2 (missing: SDL2_LIBRARY)
CMake Error at src/Platform/CMakeLists.txt:61 (message):
SDL2 library, required by Sdl2Application, was not found. Set
WITH_SDL2APPLICATION to OFF to skip building it.

This is when I removed SDL2 from framework/Headers.

That does not appear to be the case it does not try and settle SDL.framework/Headers what version of cmake are you running?
EDIT:
It appears that I was wrong. I was trying to rebuild from scratch and ran into this issue.

When SDL.framework and SDL2.framework libraries included in frameworks it causes a build problem.
This build problem causes inconsistent errors to arise.
The resolution is to use SDL2 and remove SDL.framework from /Library/Frameworks.
To solve the build problem, now for the actual cmake script I perhaps we can issue a warning since we are not supporting SDL anyways? thoughts?

To reproduce.
Download SDL.framework and SDL2.framework install in /Library/Frameworks
using the usr prefix as the installation directory.
Build Install Corrade
Generate cmake files,
run make on Magnum
at around 40 Magnum will not build correctly

Scanning dependencies of target MagnumGLLoadGenObjects
[ 1%] Building C object external/OpenGL/GL/CMakeFiles/MagnumGLLoadGenObjects.dir/gl_magnum.c.o
[ 1%] Built target MagnumGLLoadGenObjects
Scanning dependencies of target MagnumObjects
[ 2%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractFramebuffer.cpp.o
[ 3%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractImage.cpp.o
[ 4%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractObject.cpp.o
[ 5%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractTexture.cpp.o
[ 6%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractShaderProgram.cpp.o
[ 6%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Buffer.cpp.o
[ 7%] Building CXX object src/CMakeFiles/MagnumObjects.dir/ColorFormat.cpp.o
[ 8%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Context.cpp.o
[ 9%] Building CXX object src/CMakeFiles/MagnumObjects.dir/DebugMessage.cpp.o
[ 10%] Building CXX object src/CMakeFiles/MagnumObjects.dir/DefaultFramebuffer.cpp.o
[ 11%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Framebuffer.cpp.o
[ 12%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Image.cpp.o
[ 13%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Mesh.cpp.o
[ 14%] Building CXX object src/CMakeFiles/MagnumObjects.dir/MeshView.cpp.o
[ 15%] Building CXX object src/CMakeFiles/MagnumObjects.dir/OpenGL.cpp.o
[ 16%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Query.cpp.o
[ 17%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Renderbuffer.cpp.o
[ 18%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Renderer.cpp.o
[ 18%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Resource.cpp.o
[ 19%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Sampler.cpp.o
[ 20%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Shader.cpp.o
[ 21%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Timeline.cpp.o
[ 22%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/BufferState.cpp.o
[ 23%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/DebugState.cpp.o
[ 24%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/State.cpp.o
[ 25%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/TextureState.cpp.o
[ 26%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractImageConverter.cpp.o
[ 27%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractImporter.cpp.o
[ 28%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractMaterialData.cpp.o
[ 29%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshData2D.cpp.o
[ 30%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshData3D.cpp.o
[ 31%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshObjectData2D.cpp.o
[ 31%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshObjectData3D.cpp.o
[ 32%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/ObjectData2D.cpp.o
[ 33%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/ObjectData3D.cpp.o
[ 34%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/PhongMaterialData.cpp.o
[ 35%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/SceneData.cpp.o
[ 36%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/TextureData.cpp.o
[ 37%] Building CXX object src/CMakeFiles/MagnumObjects.dir/BufferTexture.cpp.o
[ 38%] Building CXX object src/CMakeFiles/MagnumObjects.dir/BufferImage.cpp.o
[ 38%] Built target MagnumObjects
Scanning dependencies of target MagnumMathObjects
[ 39%] Building CXX object src/CMakeFiles/MagnumMathObjects.dir/Math/Functions.cpp.o
[ 40%] Building CXX object src/CMakeFiles/MagnumMathObjects.dir/Math/instantiation.cpp.o
[ 40%] Built target MagnumMathObjects
Scanning dependencies of target Magnum
Linking CXX shared library libMagnum.dylib
[ 40%] Built target Magnum
Scanning dependencies of target MagnumSdl2Application
[ 41%] Building CXX object src/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o
In file included from /Users/michaelchung/CodeWorkSpaces/XCodeWorkSpace/Projects/magnum/src/Platform/Sdl2Application.cpp:25:
/Users/michaelchung/CodeWorkSpaces/XCodeWorkSpace/Projects/magnum/src/Platform/Sdl2Application.h:41:10: fatal error: 'SDL_scancode.h' file not found
#include <SDL_scancode.h>
^
1 error generated.
make[2]: *** [src/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o] Error 1
make[1]: *** [src/Platform/CMakeFiles/MagnumSdl2Application.dir/all] Error 2

Remove SDL.framework builds just fine.

ArEnSc commented Dec 25, 2013

-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Corrade: /usr/lib/libCorradeUtility.dylib
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- LIB_SUFFIX variable is not defined. It will be autodetected now.
-- You can set it manually with -DLIB_SUFFIX= (64 for example)
-- LIB_SUFFIX autodetected as '', libraries will be installed into /Developer/libs/lib
-- Could NOT find SDL2 (missing: SDL2_LIBRARY)
CMake Error at src/Platform/CMakeLists.txt:61 (message):
SDL2 library, required by Sdl2Application, was not found. Set
WITH_SDL2APPLICATION to OFF to skip building it.

This is when I removed SDL2 from framework/Headers.

That does not appear to be the case it does not try and settle SDL.framework/Headers what version of cmake are you running?
EDIT:
It appears that I was wrong. I was trying to rebuild from scratch and ran into this issue.

When SDL.framework and SDL2.framework libraries included in frameworks it causes a build problem.
This build problem causes inconsistent errors to arise.
The resolution is to use SDL2 and remove SDL.framework from /Library/Frameworks.
To solve the build problem, now for the actual cmake script I perhaps we can issue a warning since we are not supporting SDL anyways? thoughts?

To reproduce.
Download SDL.framework and SDL2.framework install in /Library/Frameworks
using the usr prefix as the installation directory.
Build Install Corrade
Generate cmake files,
run make on Magnum
at around 40 Magnum will not build correctly

Scanning dependencies of target MagnumGLLoadGenObjects
[ 1%] Building C object external/OpenGL/GL/CMakeFiles/MagnumGLLoadGenObjects.dir/gl_magnum.c.o
[ 1%] Built target MagnumGLLoadGenObjects
Scanning dependencies of target MagnumObjects
[ 2%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractFramebuffer.cpp.o
[ 3%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractImage.cpp.o
[ 4%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractObject.cpp.o
[ 5%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractTexture.cpp.o
[ 6%] Building CXX object src/CMakeFiles/MagnumObjects.dir/AbstractShaderProgram.cpp.o
[ 6%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Buffer.cpp.o
[ 7%] Building CXX object src/CMakeFiles/MagnumObjects.dir/ColorFormat.cpp.o
[ 8%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Context.cpp.o
[ 9%] Building CXX object src/CMakeFiles/MagnumObjects.dir/DebugMessage.cpp.o
[ 10%] Building CXX object src/CMakeFiles/MagnumObjects.dir/DefaultFramebuffer.cpp.o
[ 11%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Framebuffer.cpp.o
[ 12%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Image.cpp.o
[ 13%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Mesh.cpp.o
[ 14%] Building CXX object src/CMakeFiles/MagnumObjects.dir/MeshView.cpp.o
[ 15%] Building CXX object src/CMakeFiles/MagnumObjects.dir/OpenGL.cpp.o
[ 16%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Query.cpp.o
[ 17%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Renderbuffer.cpp.o
[ 18%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Renderer.cpp.o
[ 18%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Resource.cpp.o
[ 19%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Sampler.cpp.o
[ 20%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Shader.cpp.o
[ 21%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Timeline.cpp.o
[ 22%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/BufferState.cpp.o
[ 23%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/DebugState.cpp.o
[ 24%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/State.cpp.o
[ 25%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Implementation/TextureState.cpp.o
[ 26%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractImageConverter.cpp.o
[ 27%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractImporter.cpp.o
[ 28%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/AbstractMaterialData.cpp.o
[ 29%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshData2D.cpp.o
[ 30%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshData3D.cpp.o
[ 31%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshObjectData2D.cpp.o
[ 31%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/MeshObjectData3D.cpp.o
[ 32%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/ObjectData2D.cpp.o
[ 33%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/ObjectData3D.cpp.o
[ 34%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/PhongMaterialData.cpp.o
[ 35%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/SceneData.cpp.o
[ 36%] Building CXX object src/CMakeFiles/MagnumObjects.dir/Trade/TextureData.cpp.o
[ 37%] Building CXX object src/CMakeFiles/MagnumObjects.dir/BufferTexture.cpp.o
[ 38%] Building CXX object src/CMakeFiles/MagnumObjects.dir/BufferImage.cpp.o
[ 38%] Built target MagnumObjects
Scanning dependencies of target MagnumMathObjects
[ 39%] Building CXX object src/CMakeFiles/MagnumMathObjects.dir/Math/Functions.cpp.o
[ 40%] Building CXX object src/CMakeFiles/MagnumMathObjects.dir/Math/instantiation.cpp.o
[ 40%] Built target MagnumMathObjects
Scanning dependencies of target Magnum
Linking CXX shared library libMagnum.dylib
[ 40%] Built target Magnum
Scanning dependencies of target MagnumSdl2Application
[ 41%] Building CXX object src/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o
In file included from /Users/michaelchung/CodeWorkSpaces/XCodeWorkSpace/Projects/magnum/src/Platform/Sdl2Application.cpp:25:
/Users/michaelchung/CodeWorkSpaces/XCodeWorkSpace/Projects/magnum/src/Platform/Sdl2Application.h:41:10: fatal error: 'SDL_scancode.h' file not found
#include <SDL_scancode.h>
^
1 error generated.
make[2]: *** [src/Platform/CMakeFiles/MagnumSdl2Application.dir/Sdl2Application.cpp.o] Error 1
make[1]: *** [src/Platform/CMakeFiles/MagnumSdl2Application.dir/all] Error 2

Remove SDL.framework builds just fine.

@thomcc

This comment has been minimized.

Show comment
Hide comment
@thomcc

thomcc Dec 25, 2013

Fails in the same way for me. Requiring that SDL1.x not be installed on mac isn't a very good solution, if you ask me. Why isn't a qualified path to the SDL2 headers used, e.g. <SDL2/SDL_scancode.h>?

thomcc commented Dec 25, 2013

Fails in the same way for me. Requiring that SDL1.x not be installed on mac isn't a very good solution, if you ask me. Why isn't a qualified path to the SDL2 headers used, e.g. <SDL2/SDL_scancode.h>?

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc Dec 25, 2013

Good point let me try that out.

ArEnSc commented Dec 25, 2013

Good point let me try that out.

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc Dec 25, 2013

Hmm okay so I was looking at the code, I think the library developer did not consider the fact there would be library conflicts since it would be assumed that a developer would be using 2.0 SDL as stated on the main page. I am not sure why SDL 1.2 would be used is there a specific reason? but yeah the cmake script should be fixed to allow provide the direct path to the SDL 2.0 library in case of an issue where two libraries exist.

ArEnSc commented Dec 25, 2013

Hmm okay so I was looking at the code, I think the library developer did not consider the fact there would be library conflicts since it would be assumed that a developer would be using 2.0 SDL as stated on the main page. I am not sure why SDL 1.2 would be used is there a specific reason? but yeah the cmake script should be fixed to allow provide the direct path to the SDL 2.0 library in case of an issue where two libraries exist.

@thomcc

This comment has been minimized.

Show comment
Hide comment
@thomcc

thomcc Dec 25, 2013

I don't have much of a reason for keeping SDL1.x around other than that I have some old projects that depend on it that I'm fond of, but other users might have a more compelling reason to do so. I'd be surprised if there weren't people working on projects that used SDL1, because upgrading to SDL2 is not seamless. Not to mention any of the other reasons people might be required to use outdated libraries (School, work, etc).

Anyway, as I see it, the problem is that the build system fails to detect a configuration error on mac if SDL1.x and SDL2 are both installed. I think the easiest and best solution to this is to modify the build system to allow #include <SDL2/SDL_blah.h> to work on all platforms, and then use that everywhere. I guess you could also detect that SDL1.x is installed an issue an error, but that's pretty weak IMO.

This is assuming there isn't a reason that the fully qualified paths weren't used in the first place, maybe there are other platforms that prevent it (in which case the code will likely need lots of ifdef __APPLE__ and the config files will need to only change the path on mac, which is obviously the worst solution). But my guess is that it was a stylistic choice (path names in include files don't seem to be common in this library).

thomcc commented Dec 25, 2013

I don't have much of a reason for keeping SDL1.x around other than that I have some old projects that depend on it that I'm fond of, but other users might have a more compelling reason to do so. I'd be surprised if there weren't people working on projects that used SDL1, because upgrading to SDL2 is not seamless. Not to mention any of the other reasons people might be required to use outdated libraries (School, work, etc).

Anyway, as I see it, the problem is that the build system fails to detect a configuration error on mac if SDL1.x and SDL2 are both installed. I think the easiest and best solution to this is to modify the build system to allow #include <SDL2/SDL_blah.h> to work on all platforms, and then use that everywhere. I guess you could also detect that SDL1.x is installed an issue an error, but that's pretty weak IMO.

This is assuming there isn't a reason that the fully qualified paths weren't used in the first place, maybe there are other platforms that prevent it (in which case the code will likely need lots of ifdef __APPLE__ and the config files will need to only change the path on mac, which is obviously the worst solution). But my guess is that it was a stylistic choice (path names in include files don't seem to be common in this library).

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc commented Dec 25, 2013

#36

Related.

@mosra

This comment has been minimized.

Show comment
Hide comment
@mosra

mosra Dec 25, 2013

Owner

I think the easiest and best solution to this is to modify the build system to allow #include <SDL2/SDL_blah.h> to work on all platforms, and then use that everywhere.
[...]
This is assuming there isn't a reason that the fully qualified paths weren't used in the first place, maybe there are other platforms that prevent it.

This was exactly the reason for using #include <SDL_blah.h> instead of #include <SDL2/SDL_blah.h>. In SDL 1.x times some platforms had <SDL/SDL_blah.h>, some <SDL12/SDL_blah.h>, some <SDL-1.2/SDL_blah.h> etc., so detecting the directory in CMake, adding it to include path and then including only <SDL_blah.h> was the least annoying solution. Thus for me this seemed to be some kind of future-proof solution also for SDL2.

Anyway, the real problem is that the FindSDL2.cmake module isn't able to disambiguate between SDL1 and SDL2. I have an idea for a fix, but can't test it. Could you change the following line https://github.com/mosra/magnum/blob/master/modules/FindSDL2.cmake#L46 to list only SDL_scancode.h (i.e. remove SDL.h) and try clean build again? This should force CMake to find the right path and not mistake it with SDL1 one.

Owner

mosra commented Dec 25, 2013

I think the easiest and best solution to this is to modify the build system to allow #include <SDL2/SDL_blah.h> to work on all platforms, and then use that everywhere.
[...]
This is assuming there isn't a reason that the fully qualified paths weren't used in the first place, maybe there are other platforms that prevent it.

This was exactly the reason for using #include <SDL_blah.h> instead of #include <SDL2/SDL_blah.h>. In SDL 1.x times some platforms had <SDL/SDL_blah.h>, some <SDL12/SDL_blah.h>, some <SDL-1.2/SDL_blah.h> etc., so detecting the directory in CMake, adding it to include path and then including only <SDL_blah.h> was the least annoying solution. Thus for me this seemed to be some kind of future-proof solution also for SDL2.

Anyway, the real problem is that the FindSDL2.cmake module isn't able to disambiguate between SDL1 and SDL2. I have an idea for a fix, but can't test it. Could you change the following line https://github.com/mosra/magnum/blob/master/modules/FindSDL2.cmake#L46 to list only SDL_scancode.h (i.e. remove SDL.h) and try clean build again? This should force CMake to find the right path and not mistake it with SDL1 one.

@ArEnSc

This comment has been minimized.

Show comment
Hide comment
@ArEnSc

ArEnSc Dec 25, 2013

It passed the simple tests.

ArEnSc commented Dec 25, 2013

It passed the simple tests.

@mosra

This comment has been minimized.

Show comment
Hide comment
@mosra

mosra Dec 25, 2013

Owner

Solved with the mentioned fix in pull request #38.

Owner

mosra commented Dec 25, 2013

Solved with the mentioned fix in pull request #38.

@mosra mosra closed this Dec 25, 2013

@mosra mosra added this to the 2014.01 milestone Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment