Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

harry

Linux programmin' for beginners

This topic is 7140 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''m interested in porting a C++ Win32 (non-MFC) program to Linux. A couple of newbie questions... Question 1: I''ve done a bit of looking around and it appears that Linux GUI programming relies heavily on libraries - isn''t there a raw API (like the Win32 API) that can be used. Question 2: Does a Linux X-Windows program have to target a particular GUI (KDE or Gnome etc)? Or once again, is there a raw API that underlies both of these? Question 3: If the anwser to the raw API question is YES, can anybody suggest any good learning material? Any help appreciated. Harry

Share this post


Link to post
Share on other sites
Advertisement
Hello,

I have some answers to you questions that I hope prove to be useful.

1. Yes linux does rely on libraries, but so does windows, the win32 API is contained in these libraries, (for example look in the project settings in VC, to see what libraries are included just to compile a basic win32 APP).

2. From what I understand, you can use the QT libraries, to make a GUI application, and this should then work accross the board of window managers like KDE, GNOME etc.
If you want to target your APP towards something like the KDE, tehn they provide there own API to enchance your programs.

3. The learing material that I used was the documentation in Linux, if you have a full install of RH 6.0 the documentation seems to be quite good, I also use the internet alot to learn about linux/ linux programming. unforuantly I can''t give any information about books you can buy.

Anyway I hope I have helped you.

If you need any more help don''t hesitate to contact me

Paul Kinlan
PCBware LTD
www.pcbware.co.uk

Share this post


Link to post
Share on other sites
Well,
QT is just one of many GUI toolkits (and underlies KDE, in fact.) Similarly, GTK is another toolkit, which was used to create GNOME. To really answer your question, yes. You can create a flat X-Windows (X11R6) program that only uses Xlib. Xlib is the lowest level library in X, on top of which everything else is built. This includes window managers, widget toolkits (Motif, Qt, ...) and anything else. However, you will very quickly discover that writing in Xlib is nasty. Really nasty.

Historically, many people have used Motif (all the old versions of Netscape, and hordes of other apps) which was a GUI toolkit that provided widgets, and a standard look and feel. The only problem is that the standard looks and feels like ass.

Nowadays, most people seem to be writing their programs to use either GTK or QT. Personally, I also like fltk (www.fltk.org). Ultimately, most systems will have these libraries installed. If you really don''t want to require that your user install them, though, you can always just statically link your program, and the libraries won''t even be needed. (Well, they''ll still need the lower level Xlib libraries, but you need them to run X, so everyone has them.)

I''m rambling, but I hope I answered your question.

-Brian

Share this post


Link to post
Share on other sites
To more fully answer your question: Yes, there is a basic tool kit. It''s called Xlib. Do Not Use It.

Why?

Here is a simple comparison: In QT, it takes 20 lines to open a window. In Xlib, this takes 200 lines. I know. I just wrote a simple Xlib Api.

Additionally, xlib is poorly documented in certain areas, specifically the XImage structures you need to draw images, rather than the std xlib primatives (lines, curvers, words, etc). (if you can prove me wrong by finding me one source longer than a page, that describes the data format as well as the image, I swear I''ll eat my hat).

Since the library is written to go from the very basics, its fairly difficult to get a grip on initially. If you want to, and have about 2 months free, I recommend the following books (Both! Each on its own is very little use IHMO):

Xlib Programming Manual (for version 11, release 4)
O''Reilly & associates, Inc.

X Window System Programming
SAMS

and probably: Xlib Reference Manual (for ver 11, rel 4)
too. They are very. very. useful. Vastly better than the man pages or online documentation / tutorials.

I''m very serious here; if you want to learn xlib, buy the books and learn it; it''s kinda cool to know. But not if you just want to quick way to draw an interface.

The libraries are much better...but as always, tend to lack functionality for something you specifically want to do (for me complicated pixmap buffering).

(Nb. Don''t worry the books are rel 4 and currently its rel 6 or so...I don''t think any newer books are out there...Anyone know?)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!