Can' run program on computer w/o libSDL2 installed |
Can' run program on computer w/o libSDL2 installed |
MrOzBarry
|
You might just be able to do a soft link from wrote:
|
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Holth
Guest
|
You can use rpath to instruct the linker to find a bundled libsdl relative to your executable, or run it from a wrapper script that sets ld_library_path.
Great care must be taken to avoid linking to distro specific symbols. See also the steam runtime for an example of linking with controlled dependencies. On Apr 8, 2015 2:50 AM, "bilsch01" wrote:
|
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Gibson
Guest
|
On 04/08/2015 05:40 PM, Alex Barry wrote:
That won't work at all if libsdl is just not installed on that system. You either want static linking, try: gcc -o bla `sdl2-config --cflags` -static `sdl2-config --static-libs` bla.c or you bundle libsdl2.so.0 with your application and use RPATH $ORIGIN, see http://jorgen.tjer.no/post/2014/05/20/dt-rpath-ld-and-at-rpath-dyld/ Cheers, Daniel
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
|
|||||||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Gibson
Guest
|
On 04/08/2015 10:38 PM, bilsch01 wrote:
this means you're missing the corresponding -dev packages. But probably the libSDL2 supplied by distributions is not optimal for this anyway, as it links against all those libs - if you build it yourself with default flags, most of the libs will be loaded with dlopen(), if they're available, and thus don't need to be linked against. When I execute sdl2-config --static-libs from a custom build, I get the following output: $ ./sdl2-config --static-libs -L/tmp/lib -Wl,-rpath,/tmp/lib -lSDL2 -lpthread -Wl,--no-undefined -lm -ldl -lts -lpthread -lrt so it only seems to link against things from glibc and SDL2 itself. Cheers, Daniel _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
[quote="Daniel Gibson"]On 04/08/2015 10:38 PM, bilsch01 wrote:
if you build it yourself with default flags, most of the libs will be loaded with dlopen(), if they're available, and thus don't need to be linked against. When I execute sdl2-config --static-libs from a custom build, I get the following output: $ ./sdl2-config --static-libs -L/tmp/lib -Wl,-rpath,/tmp/lib -lSDL2 -lpthread -Wl,--no-undefined -lm -ldl -lts -lpthread -lrt so it only seems to link against things from glibc and SDL2 itself. Cheers, Daniel Thanks for your response. I don't understand what the output above tells us. How does it tell what files to static link with my program? The file libSDL2.a has hundreds of unrecognized references in it. I am linking with all of the libSDL2 ... '.a' files in directory /usr/lib/i386-linux-gnu. I searched some of the unrecognized references and they seem to be in other files in the same directory but I only checked a few of many. I do have a top level package file for the whole library: libsdl2-2.0-0_2.0.2+dfsg1-3ubuntu1_i386.deb but the file is older than the libraries on my system. Can you recommend a course of action for me. Please be specific I'm not all that savvy. |
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Gibson
Guest
|
On 04/09/2015 01:19 AM, bilsch01 wrote:
* download libSDL sourcecode * extract it * go into the extracted directory (in terminal) * mkdir mybuild * cd mybuild * ../configure --prefix=/home/yourname/SDL2/ * make * make install In /home/yourname/SDL2/ you'll find an include/ directory with the headers, a lib/ directory with the dynamic and static libs and a bin/ directory with sdl2-config in it. Use /home/yourname/SDL2/bin/sdl2-config --cflags and /home/yourname/SDL2/bin/sdl2-config --static-libs when compiling to get the needed compilerflags for the build. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Gabriele Greco
Guest
|
I do my release builds on a virtual machine running debian lenny with a self built GCC 4.8.3 (to be able to use C++11 goods) using a self built SDL (2.0.3) with --enable-static --disable-shared in configure script, so SDL2 (that is not bundled in debian lenny) can be linked only statically.
I link with --static-libgcc --static-libstdc++ so, since SDL dynamically loads his dependencies, I run essentially without any external, distro specific dependency. The binaries built in this way runs on any linux distro of the last 10 years. On Thu, Apr 9, 2015 at 1:28 AM, Daniel Gibson wrote:
-- Ing. Gabriele Greco, DARTS Engineering Tel: +39-0100980150 Â Fax: +39-0100980184 s-mail: Piazza Della Vittoria 9/3 - 16121 GENOVA (ITALY) |
|||||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
[quote="Daniel Gibson"]On 04/09/2015 01:19 AM, bilsch01 wrote:
* download libSDL sourcecode * extract it * go into the extracted directory (in terminal) * mkdir mybuild * cd mybuild * ../configure --prefix=/home/yourname/SDL2/ * make * make install In /home/yourname/SDL2/ you'll find an include/ directory with the headers, a lib/ directory with the dynamic and static libs and a bin/ directory with sdl2-config in it. Use /home/yourname/SDL2/bin/sdl2-config --cflags and /home/yourname/SDL2/bin/sdl2-config --static-libs when compiling to get the needed compilerflags for the build. _______________________________________________ Thanks for your help. I had problems along the way. SDL site does not offer the source package for linux for download directly. They say use the linux package manager to get and install SDL 2.0.3. I found an older version for download: SDL2-2.0.0.tar.gz from 2013. I uninstalled my up-to-date SDL and then did as you instructed: configure, make, make install with the older version but it got an error during mske install step. Error says: cannot create regular file '/usr/local/lib/libSDL2-2.0.so.0.0.0': Permission denied I could not figure this out since there is no other file from any other version of SDL at that path. I did not end up with the exact files and directory structure that you mentioned in your instructions: no bin directory anywhere and no lib directory. AT that point I abandoned the experiment and cleaned out my system and installed the current version of SDL. Bill S. |
|||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
Christian Knudsen
|
The source code download is the very first thing on the SDL2 download page. It says "Source Code". |
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Sik
|
2015-04-12 7:33 GMT-03:00, Christian Knudsen:
Source package is not the same thing as source archive (although admittedly if you get the source code you may as well just build it). _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
[quote="Daniel Gibson"]On 04/09/2015 01:19 AM, bilsch01 wrote:
* download libSDL sourcecode * extract it * go into the extracted directory (in terminal) * mkdir mybuild * cd mybuild * ../configure --prefix=/home/yourname/SDL2/ * make * make install In /home/yourname/SDL2/ you'll find an include/ directory with the headers, a lib/ directory with the dynamic and static libs and a bin/ directory with sdl2-config in it. Use /home/yourname/SDL2/bin/sdl2-config --cflags and /home/yourname/SDL2/bin/sdl2-config --static-libs when compiling to get the needed compilerflags for the build. _______________________________________________ OK Daniel. I got the current source code and followed all your instructions. It's the last step that's not working. Maybe I'm not doing it right. I used the two following command lines: 1) gcc graf.c -o graf1 -lm '/home/bill/SDL2/bin/sdl2-config --cflags' '/home/bill/SDL2/bin/sdl2-config --static-libs ' 2) gcc graf.c -o graf1 -lm /home/bill/SDL2/bin/sdl2-config --cflags /home/bill/SDL2/bin/sdl2-config --static-libs The first says: gcc: error: /home/bill/SDL2/bin/sdl2-config --cflags: No such file or directory gcc: error: /home/bill/SDL2/bin/sdl2-config --static-libs : No such file or directory The second says: gcc: error: unrecognized command line option ‘--cflags’ gcc: error: unrecognized command line option ‘--static-libs’ |
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Gibson
Guest
|
On 04/13/2015 10:13 AM, bilsch01 wrote:
Not '/home/bill/SDL2/bin/sdl2-config --cflags' but `/home/bill/SDL2/bin/sdl2-config --cflags` ` (backtick) instead of ' _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
[quote="Daniel Gibson"]On 04/13/2015 10:13 AM, bilsch01 wrote:
Not '/home/bill/SDL2/bin/sdl2-config --cflags' but `/home/bill/SDL2/bin/sdl2-config --cflags` ` (backtick) instead of ' _______________________________________________ Thanks for your help. The backticks got the program to compile with no problem. But the executable end product has the same problem when run on a computer without libSDL2 installed. It says: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory Apparently the static libraries didn't get linked in. The new file is only 5 bytes larger than the dynamic link one - which seems odd. Bill S. |
|||||||||||||
|
Can' run program on computer w/o libSDL2 installed |
Daniel Gibson
Guest
|
On 04/14/2015 03:05 AM, bilsch01 wrote:
And you also added `/home/bill/SDL2/bin/sdl2-config --static-libs` ? Also, make sure there is *no* "-lSDL2" or similar in the line (which would add dynamic linkage against sdl2 after all) Hmm, maybe try "--static" before `/home/bill/SDL2/bin/sdl2-config --static-libs` _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
bilsch01
|
[quote="Daniel Gibson"]On 04/14/2015 03:05 AM, bilsch01 wrote:
And you also added `/home/bill/SDL2/bin/sdl2-config --static-libs` ? Also, make sure there is *no* "-lSDL2" or similar in the line (which would add dynamic linkage against sdl2 after all) Hmm, maybe try "--static" before `/home/bill/SDL2/bin/sdl2-config --static-libs` _______________________________________________ I tried this: gcc graf.c -o graf1 `/home/bill/SDL2/bin/sdl2-config --cflags` --static `/home/bill/SDL2/bin/sdl2-config --static-libs ` I got errors familiar from earlier: /home/bill/SDL2/lib/libSDL2.a(SDL_dynapi.o): In function `get_sdlapi_entry': /home/bill/sdl2src/SDL2-2.0.3/src/dynapi/SDL_dynapi.c:227: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: cannot find -lts collect2: error: ld returned 1 exit status |
|||||||||||||
|
Re: Can' run program on computer w/o libSDL2 installed |
Christian Knudsen
|
Fair enough, but the instruction given in this thread was to "download libSDL sourcecode". |
|||||||||||||||||
|