Jump to content
  • Advertisement
Sign in to follow this  
CoMaNdore

sdl on ubuntu

This topic is 5007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I am a complete noob to linux. And I wanted to give it a try so I whent and installed ubuntu. Worked like a charm. Now I have gcc gotten up and running and I am able to compile projects with multiple source files. Now the thing is that I want to install SDL so I can port some of my simpler games from win to linux. How can I do this? I have downloaded the rpm packet from the libsdl.org site, but I am unable to install it. Error message:
Quote:
$ sudo rpm -i SDL-devel-1.2.8-1.i386.rpm rpm: To install rpm packages on Debian systems, use alien. See README.Debian. error: cannot open Packages index using db3 - No such file or directory (2) error: cannot open Packages database in /var/lib/rpm
Remember that I am a noobie on linux so please "talk to me like im 3 years old"(TM).

Share this post


Link to post
Share on other sites
Advertisement
you have sort of got the right idea there.. A lot of Linux distros use red hat package manager (rpm), except debian and ubuntu derivatives. They use something called .debs, alien is a program that converts .rpm into .deb (I don't understand why they don't have a program called rpm that will do it for you, and output an error message). Unfortunately I can't help you myself (use SUSE 9.2), but Here is what alien is and Was the best I could find on how to use alien. You could also try alien --help and see what it outputs.

Share this post


Link to post
Share on other sites
I'd recommend you just download the SDL source code and build it yourself. It's not too hard at all. Just uncompress the source, and:

./configure
make
su <---- if you're not running as su already, you'll have to do it here
make install

Hope this helps!


Ryan

Share this post


Link to post
Share on other sites
There's a .deb distribution of sdl on the ubuntu apt repositorys. You should be able to get it with the Synaptic package manager. You'll need the latest sdl and sdl-devel packages.

If you can't find it in Synaptic you might need to add the universe repositorys (read this).

Really, you should avoid rpms unless absolutely nessesary and stick to synaptic or apt get.

Hope that helps

Share this post


Link to post
Share on other sites
Quote:
Original post by mrbastard
There's a .deb distribution of sdl on the ubuntu apt repositorys. You should be able to get it with the Synaptic package manager. You'll need the latest sdl and sdl-devel packages.

If you can't find it in Synaptic you might need to add the universe repositorys (read this).

Really, you should avoid rpms unless absolutely nessesary and stick to synaptic or apt get.

Hope that helps


Yeah, just fire up a bash prompt, and do this:

thec@12[~]$ su
Password: <enter your password here>
thec@12[~]# apt-get install libsdl-dev
...
thec@12[~]# exit


And you're done... but synaptic is a great frontend to apt-get too, just quicker to use the bash prompt :)

Albert

Share this post


Link to post
Share on other sites
Okay I did like thec said.

Now how do I compile a sdl app?

I tried this:

/////////////////////////////////
// test.cpp
// A simple sdl test by Timon
//
//
#include <iostream>
#include <SDL\SDL.h>
#pragma comment(lib, "SDL.lib" )

int main( int argc, char* argv[] )
{
printf( "Hallo from SDL\n" );

return( 0 );
}


Makefile:

# makefile for sdl test
#

# flags
CFLAGS=-W -Wall -ggdb

CC=cc # compiler
FILES=test.cpp #file
TARGET=sdltest #out

demo:
$(CC) $(FLAGS) $(FILES) -o $(TARGET)


Now I try to run make i get this error:
Quote:

$ make
cc test.cpp -o sdltest
test.cpp:7:21: SDL\SDL.h: No such file or directory
make: *** [demo] Error 1

Share this post


Link to post
Share on other sites
Change "SDL\SDL.h" to "SDL/SDL.h". Also, you'll want to add `sdl-config --libs` (note the `(grave), not '(quote)) when you link(The "#pragma comment" thing only works on VC, I believe. Although most compilers (including GCC) ignore all unknown #pragmas, so you can leave it in)

Quote:
Original post by Ryan Clark
su <---- if you're not running as su already, you'll have to do it here
<nitpick> Su stands for Substitute User identity, you mean 'if your not running as root already'. </nitpick>

Share this post


Link to post
Share on other sites
Sry to ask more about this but I think somthing is wrong with my Makefile.

After I did the changes It still wont compile:
Quote:

$ make
cc test.cpp -o sdltest
/tmp/ccqjWDw5.o(.text+0x41): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccqjWDw5.o(.text+0x72): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccqjWDw5.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [demo] Error 1


I also removed the #pragma comment thing.
Dont I need to include the SDL.lib in some kind of way too?

Thanks for the good help and fast replies. Im almost sure that it will be the last question..

Share this post


Link to post
Share on other sites
cc isn't linking with the C++ library, you should either add the option '-lstdc++' or use the g++ command.

About SDL.lib (linux uses .a files, not .lib, by the way), I mentioned it in my previous post: Add `sdl-config --libs` (the `s are graves (same key as ~, at least on most keyboards), not quotes, and they're required) as an argument for g++.

Share this post


Link to post
Share on other sites
I had added the flag " `sdl-config --libs`" to my flag var.
But I dint know what it did before now, thanks!

I change the compiler into g++ and the stample code that I posted above worked.

Now I get unresolved error everytime I try to use a SDL function.

/tmp/ccCT7Fv9.o(.text+0x18): In function `main':
: undefined reference to `SDL_Init'
/tmp/ccCT7Fv9.o(.text+0x1d): In function `main':
: undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
make: *** [demo] Error 1


Any ideas?

[Edited by - CoMaNdore on March 4, 2005 6:02:47 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!