How to build native binary with SDL2 library using sdl2-config script on Linux?


(Juraj Michálek) #1

I want to compile C application which uses SDL2 C library (http://www.libsdl.org) SDL2 on Linux contains config script which returns set of parameters for compiler/linker. Script: sdl2-config --libs Returns: “-L/usr/lib/x86_64-linux-gnu”, “-lSDL2”

This could be translated to following configuration:

executables {
    main {
        binaries.all {
           if (toolChain in Gcc) {
                linker.args "-L/usr/lib/x86_64-linux-gnu", "-lSDL2"
            }
        }
    }
}

How could I replace linker.args to use dynamic call of ‘sdl2-config --libs’ instead of hardcoded values? Something like “sdl2-config --libs”.execute(). People use often back quote sign (eval) in Makefiles to achieve this: ‘sdl2-config --libs’