Sign in to follow this  

Programming on linux

This topic is 4333 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

Hi, I've programmed a lot on windows, but I would like to make my programs on linux available too. I've been searching a lot how to do it on linux, like making a window etc, but I don't get it. What does X-window, Gnome and KDE mean? And do I have to make different versions of my program for different linux distributions, like Suse, Mandrake, Redhat etc, or does it run on all of them? Are there any good tutorials on this subject. I'm programming in C++. thanks, Gerben VV

Share this post


Link to post
Share on other sites
X-Windows is the name of the most prevalent windowing system available for *nix machines. Gnome and KDE are window managers, which is something that exists on top of the windowing system that actually draws and manages the windows that applications create. Depending on how you code an X-Windows application, it can be tied to a specific window manager like Gnome or KDE, or it can run on anything that supports the version of XLib that you used to create your application.

If you want to actually do linux game programming, I would just use a cross platform library like SDL.

Share this post


Link to post
Share on other sites
Unix uses a way to handle graphics that is quite old but stable and flexible, called X. It allows for graphics systems to communicate through a network and a ton of other features. On top of that API is the window manager. What it does is basicly handle window creation and management, for example there's Sawfish (I think it's what Gnome uses) and I think enlightenment is one too. On top of that you can have a desktop enviroment (which is like desktop icons, start menu, etc.), as examples there are KDE and Gnome (the most popular). To code graphics systems on Linux, you need to code for the X system (which handles all the graphics). But because X is so powerful and complex, it can become hard to code. That's why there are GUI toolkits which make it easier to create GUIs, windows, etc. Most GUI toolkits are cross-platform too.

If you want to learn how to code programs on Linux for X, you should either search for Xlib tutorial (the library you use to create the windows and to draw on them) or use an already available toolkit like FOX, FLTK, wxWindows, Qt, Gtk, etc. You should search the net for them and see which one you find easier to use. Hope this helps,

JVFF

Share this post


Link to post
Share on other sites
X-windows [or x.org] are the system used to draw windows on the screen

KDE and Gnome are window managers, they define their own styles, have their own api, and have lots of useful applications [like konqueror in KDE the eqlivent of IE in windows [including the file management stuff]]

if you use a library like wxwidgets you can write applications abstracted away from the differences of different window mangers and also abstracted away from the differences of different operating systems [your thing should be able to compile and run on windows too... and OSX if I recall]

there are essentially two differences between distributions in this context.
1. different package management systems [kind of like wether your app is in its own executable, or a special archive, or another type of special archive... The tools coming with each distro usually only support one type of package]
2. different library versions. some distributions don't by default come with a particular version of the c standard library or other things your program might depend on. So your program would have to be recompiled for the distribution.


you could distribute your program in a tgz archive [instead of a rpm, deb, or gentoo package], but then it wouldn't install in the expected place [unless you did it like slackware, where to install something you extract it at / ]. As long as you require versions of libraries that the current distros include this would be the best approach.


SuSe, redhat, mandrake, fedora all use rpm
gentoo has its own package thing
debian-derived distros use deb packages [mepis, ubuntu, kubuntu, knoppix,...]

Share this post


Link to post
Share on other sites
Well, I use openGL right now, and that works on linux too, so I'm more interesting in how to set openGL up on linux. I have a special settings program, which is a window with buttons, input boxes, etc. I could use Qt for that.

Share this post


Link to post
Share on other sites
I personally have not used Qt so i cannot vouch either way. However if you have code already written for OpenGL, i'de highly suggest re-writing your code to utilize SDL (libsdl.org) instead of the Win32 API (or whatever it is currently). SDL is cross platform compatible to the major *nix distrobutions.

My development environment changes multiple times throughout a single day. Win32/64, MAC OSX, Gnome/KDE. I transport my code via a thumbdrive and never have issues compiling and/or running.

Do some research though about what you want to do. Qt, Gtk, wxWidgets, etc may be more suited.

Share this post


Link to post
Share on other sites
For starters, if you want to be making programs in linux, make them in linux. Get yourself a distro on a computer (you can dual boot linux and windows) and start writing applications for linux (Java, C, C++, python, etc..) now, once you've written apps in linux you can port them easily to windows by using the MSYS (mingw) or cygwin cross-compiler environments. The SDL site actually had a nice script to do this automatically but I think it has been outdated for some time.

Basically, there is no EASY way to cross-compile your code. You need to familiarize yourself with linux and windows before you can compile for both operating systems. By-far you do NOT need to be an expert in either OS, but you should know basic commands for compiling in Linux.

Quote:

I personally have not used Qt so i cannot vouch either way. However if you have code already written for OpenGL, i'de highly suggest re-writing your code to utilize SDL (libsdl.org) instead of the Win32 API (or whatever it is currently). SDL is cross platform compatible to the major *nix distrobutions.


This is not correct at all, OpenGL is cross-platform and will work on windows, linux, macos, and more. I do not suggest DOWNGRADING to SDL if you are already using OpenGL. When SDL2 comes out the whole API will rely on OpenGL and will be much better suited for what you're talking about, but until then, stick with OpenGL and maybe use SDL for input, fi/fo, audio, and network. Since SDL provides cross-platform APIs for all those.

Gnome/KDE will have very little to do with your actual programming, unless you want to program specifically for certain aspects of GNOME or KDE (such as the graphical front-end applications and widgets).

Share this post


Link to post
Share on other sites
Quote:
Original post by eastcoastsurfer
Why would SDL be a downgrade? Everytime I've used SDL it's been in conjunction with OpenGL.


I think that's more of a rant than anything else. SDL has it's problems though - it doesn't seem to agree with multiple screens (I've recently been suffering this since an upgrade). It's limited in some ways like you can only have one window, but if it does all you need there's not a lot wrong with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by gerbenvv
Yeah, but for SDL I have to change my whole program, while I only have to change the setup code. Maybe I'll use Xlib.


Why? SDL handles window creation, input, sound and so on. All of those things are different in Win32 to Xlib/Linux, so you'll have to rewrite all of that anyway. Since SDL can be used to create an OpenGL window, you get to keep the OpenGL code.

Share this post


Link to post
Share on other sites
Quote:
Original post by eastcoastsurfer
Why would SDL be a downgrade? Everytime I've used SDL it's been in conjunction with OpenGL.


Using the SDL drawing API is not in OpenGL. It is very slow and you can't do much with it without slowing the frame rate a lot. My original post in this thread was aimed at that fact. Someone said to stop using OpenGL and use SDL... which makes no sense because you can use OpenGL drawing routines in conjunction with SDL.

Share this post


Link to post
Share on other sites
Quote:
Original post by wyled
Quote:
Original post by eastcoastsurfer
Why would SDL be a downgrade? Everytime I've used SDL it's been in conjunction with OpenGL.


Using the SDL drawing API is not in OpenGL. It is very slow and you can't do much with it without slowing the frame rate a lot. My original post in this thread was aimed at that fact. Someone said to stop using OpenGL and use SDL... which makes no sense because you can use OpenGL drawing routines in conjunction with SDL.


Ah, I think you might have misread that comment. It said if you already had your code in OGL + Win32, rewrite the win32 parts in SDL. I'm no SDL expert though, I wasn't even aware it had it's own drawing functions since I've only used it for input and basic window creation functionality when doing stuff with OGL.

Share this post


Link to post
Share on other sites
Well, In fact I use openAL for sound which is cross-platform too. And for the window creation I have a special class, so I'm better off making new code for the openGL and window init. I get Xlib to work, so I'm just gonna read some Xlib openGL and window init tutorials and code them.

Thanks,
Gerben VV

Share this post


Link to post
Share on other sites
Quote:
Original post by nmi
If you want to start simple, you should give Qt a try:
http://www.trolltech.com/products/qt/index.html

It is C++ and cross-platform for linux and windows. An open-source version of Qt4 is available.


One thing to be aware of is that if you aren't willing to release your source code under the GPL, a commercial Qt license isn't cheap (IIRC something like $1,000 per developer).

Share this post


Link to post
Share on other sites

This topic is 4333 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this