Generate executable with no dependencies on Linux

322 views Asked by At

I wanted to compile a task using SDL in C++ and I wanted to run the generated executable on another Linux that does not have this library installed, so how can I compile it in a way that I can include dependencies of SDL for running on another computer with Linux without the SDL installed?

2

There are 2 answers

0
keltar On BEST ANSWER

You can just deploy your program with libraries it needs and use LD_LIBRARY_PATH to specify where to look for libs. It will allow user to use newer versions of libraries. (latest SDL2 already have this even if linked statically, but it isn't the same for other libraries).

If you don't have static libSDL.a (or libSDL2.a), you can easily build it. Standard build will produce both .a and .so, or use --enable-static if for some reasons your configuration is different.

0
David St Pierre On

Embed SDL into your source by including the header files into your projects when compiling. You can get the source files from the SDL site.