views:

347

answers:

2

So I have this very simply SDL application I want to be able to pass to my friend without having him download a whole bunch of SDL packages.

how can I go about this? I was told to use this line to compile: (note that I use ubuntu linux and so does my friend, and that this application compiles and runs without the "-Wl,-Bstatic" options just fine.)

    g++ test-sdl.cpp -o test-sdl -Wl,-Bstatic -lSDL_image -lSDL

But then I get this error:

    /usr/bin/ld: cannot find -lgcc_s  
    collect2: ld returned 1 exit status

why am I getting this error? how do I fix it? do I even have to do this in this way? Is there a different/easier/alternative way?

Am I asking for so much by wanting to save my friend the hassle of downloading packages he will probably never use anyway?

Thanks.

+2  A: 

You should get rid of the -B, I think (this changes the search path, see man g++, and thus you can't find your libraries anymore).

The switch you meant is -static, without the B.

Edit in response to comments: sorry, that was incomplete. Instead, replace all of "-Wl,-Bstatic" with just "-static".

As codelogic wrote, -static is not an option to the linker (which -Wl implies).

yungchin
this: g++ test-sdl3.cpp -o test-sdl3 -Wl,-static -lSDL_image -lSDLdoes not work either. It returns the same error.
ramy
-static is not a linker option, it's a gcc option.
codelogic
this: g++ -static test-sdl3.cpp -o test-sdl3 -Wl,-lSDL_image -lSDLand this: g++ -static test-sdl3.cpp -o test-sdl3 -lSDL_image -lSDLreturn an identical stack of errors so big my terminal does not remember enough lines for me to see the first error output.
ramy
+2  A: 

In the long run your best bet would be to figure out how to build .debs and then your friend's system's package management can take care of installing all the dependencies needed. If you want to distribute the packages more widely, using the platform's native packaging system as intended will save you and your users a lot of headaches.

Take a look at Ubuntu's guide to packaging and pbuilder.

Personally, I learned how to do this for my own projects (on Debian) from the Martin Krafft Debian book, and find using yada streamlines the process considerably.

timday
hmm it would seem this is a more logical alternative. By having me install the debs for him through my own deb. Is there a way for me to determine exactly which packages are necessary (in order to install the least amount of packages necessary to get the app running)
ramy
Yes look at the man page for dpkg-depcheck - you should be able to use it on your app to get a list of all the packages your app is dependent on when it runs. (I've seen other methods involving processing strace output too).
timday