Simple Directmedia Layer
Go to file
Sam Lantinga f86af130f5 Fixed bug 2795 - SDL library detection selects the wrong lib
Chris Beck

When creating a homebrew recipe for wesnoth, I discovered that the SDL image configuration routine does not detect libpng properly -- if you have multiple instances of libpng on your system, and you use environment variables to select an instance which is not in your system directory, the build can be broken, because it will run configuration tests against the system installed version, but deduce that it should use the filename of the system-installed version. In a vanilla build of wesnoth using homebrew, this results in segfaults at runtime, because you end up linking against two different versions of libpng, which is also needed independently of SDL.

The problem is essentially in the "find_lib" routine in the configure file:



find_lib()
{
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
        lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
        if test x$lib != x; then
            echo $lib
            return
        fi
    done
}



Because the for loop goes over the system directories before the environment directories, any system-installed lib will shadow the lib selected via environment variables. This is contrary to the behavior of the configuration tests earlier in the script, which prefers the environment variable libs over the system-installed libs. The 'for' loop should instead be:



    for path in $env_lib_path $gcc_bin_path $gcc_lib_path /usr/lib /usr/local/lib; do



You can see the full discussion on the Homebrew / linuxbrew issue tracker here: https://github.com/Homebrew/linuxbrew/issues/172

I have checked that this bug also affects SDL 1.2.15, SDL_mixer and SDL_ttf 1.2, which all use this same "find_lib" routine. I have not determined if the bug affects SDL 2.0, which seems not to use this exact routine.
2014-11-29 14:41:18 -08:00
VisualC Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
VisualC-WinRT Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Xcode add controllermap program to SDLTest xcode project 2014-11-23 15:21:49 -05:00
Xcode-iOS Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
acinclude Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
android-project Added name for second Java Thread on Android. 2014-11-23 20:35:51 +01:00
build-scripts Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
cmake Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
debian Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
docs WinRT: bug and data-integrity fixes for SDL_GetPrefPath() 2014-11-29 10:09:30 -05:00
include Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification 2014-11-29 11:49:58 -08:00
premake Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
src Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification 2014-11-29 11:51:13 -08:00
test add "i" shortcut to testgesture tool to log # of fingers down on the touch devices. 2014-11-23 15:39:28 -05:00
visualtest Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
.hgignore Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Android.mk Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
BUGS.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
CMakeLists.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
COPYING.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
CREDITS.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
INSTALL.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Makefile.in Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Makefile.minimal Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Makefile.pandora Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Makefile.psp Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Makefile.wiz Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
README-SDL.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
README.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
SDL2.spec.in Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
TODO.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
VisualC.html Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
WhatsNew.txt Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
autogen.sh Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
cmake_uninstall.cmake.in Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
configure Fixed bug 2795 - SDL library detection selects the wrong lib 2014-11-29 14:41:18 -08:00
configure.in Fixed bug 2795 - SDL library detection selects the wrong lib 2014-11-29 14:41:18 -08:00
sdl2-config.in Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
sdl2.m4 Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
sdl2.pc.in Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00

README.txt

                         Simple DirectMedia Layer

                                  (SDL)

                                Version 2.0

---
http://www.libsdl.org/

Simple DirectMedia Layer is a cross-platform development library designed
to provide low level access to audio, keyboard, mouse, joystick, and graphics
hardware via OpenGL and Direct3D. It is used by video playback software,
emulators, and popular games including Valve's award winning catalog
and many Humble Bundle games.

More extensive documentation is available in the docs directory, starting
with README.md

Enjoy!
	Sam Lantinga				(slouken@libsdl.org)