How to build static sdl2 with dependencies included?

Currently if you want to link SDL2 as static library you must also link it’s dependencies which are listed in sdl2-config --static-libs output. Is it possible to build SDL2 with dependencies already included, so that linking with SDL2 and maybe SDL2main would be enough?

Yes. You can combine static libraries into other static libraries. libtool might
make a fuss about it (surprise), but ar won’t.On 08/07/2013 02:56 PM, riptor wrote:

Currently if you want to link SDL2 as static library you must also link it’s
dependencies which are listed in sdl2-config --static-libs output. Is it
possible to build SDL2 with dependencies already included, so that linking with
SDL2 and maybe SDL2main would be enough?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

ar does the job, but maybe there’s some compilation key to automate the process?
Now I have to compile sdl, then get libraries list for linking, then add those libraries to sdl and only then I can link the library with my executable. But compilation script already knows exactly which libraries it needs, so why don’t we ask the script to add them?

I suspect the reason is that C and its library system was explicitly designed
for modularity and that’s how the tools evolved. If you’re using a unix-y build
system, then you don’t need to track down any libs because sdl-config lists
them for you. If you’re on Windows, the initial setup is cumbersome, but you
only have to do it once. The simplest/dumbest way is to create one massive
solution with all the lib projects and all the app targets – and try not to
trigger a re-build.On 08/08/2013 03:02 AM, riptor wrote:

ar does the job, but maybe there’s some compilation key to automate the process?
Now I have to compile sdl, then get libraries list for linking, then add those
libraries to sdl and only then I can link the library with my executable. But
compilation script already knows exactly which libraries it needs, so why don’t
we ask the script to add them?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2013/8/7 riptor

**
Currently if you want to link SDL2 as static library you must also link
it’s dependencies which are listed in sdl2-config --static-libs output. Is
it possible to build SDL2 with dependencies already included, so that
linking with SDL2 and maybe SDL2main would be enough?

You can link SDL2 (and SDL2_image, etc) almost entirely statically. On
Linux, you have to link to libpthread, libdl and libc and dynamically
though, no way around it. Also, SDL2 by default will load OpenGL/X11
dynamically via dlopen (it will not even be listed with ldd), so you have
that dynamic dependency as well. So, while making a big static binary blob
has some advantages from a distribution point of view, there’s a bunch of
limitations that prevent you from fully accomplishing this.–
Gabriel.