Linux API

This is a discussion on Linux API within the Linux Programming forums, part of the Platform Specific Boards category; can some one point me in the direction of a good tutorial preferably on the internet that will teach me ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    224

    Linux API

    can some one point me in the direction of a good tutorial preferably on the internet that will teach me or guide me through the process of making a program in linux(so it looks like a window would in windows(not dos))...

    And one more quick q. does each WM like blackbox and Gnome have different functions for making a window?

    thx

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    no they are all built on top of the X window system, the call to make a window in any will make it in the other.

    Linux doesn't have an API, you still use system calls (remember old old dos programming? yeah, like that)

    However, Xfree86 (the gui system that gnome or kde, etc runs on top of) does have a sort of api. Look up that.
    PHP and XML
    Let's talk about SAX

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    could you give me a quick example of what you mean...
    like just make a window that says something in it...
    thx

  4. #4
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    A window in gtk with a button that says hey
    Code:
    #include <gtk/gtk.h>
    
    int main(int argc,char *argv[]){
         GtkWidget *window, *button;
         window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
         gtk_container_set_border_width(GTK_CONTAINER(window),10);
         gtk_window_set_title(GTK_WINDOW(window),"Linux gtk");
         gtk_signal_connect(GTK_OBJECT(window),"destroy",
                                         GTK_SIGNAL_FUNC(gtk_exit),NULL);
         button=gtk_button_new_with_label("hey");
         gtk_widget_show(button);
         gtk_container_add(GTK_CONTAINER(window),button);
         gtk_widget_show(window);
         gtk_main();
         return 0;
    }
    Of course there are others like qt and xam but I don't know those

  5. #5
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    thanks for replying to him, i didn't have a linux box in front of me to throw something together on....now compare that with the basic windows api window...a lot less code.
    PHP and XML
    Let's talk about SAX

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    thanks

    do you guys know were i can find a tutorial on what you just wrote...
    i never programmed anything more than basic text stuff with dos

  7. #7
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    this is called gtk as stated earlier. Go to www.gtk.org and then click 2.0 tutorial on the left. If you have a basic install of linux like gnome or kde you automatically have gtk. Then they can teach you all they know.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The "Linux API" for the core calls is the POSIX library, which is made available as part of the GNU C library. Which means that using it is no more effort than using the standard C functions. This libary contains stuff like browsing directories.

    Graphical libraries are all based on XLib, which is very lowlevel and unpleasant to use. The most popular libraries are GTK+, which is used by Gnome, and Qt, which is used by KDE. The next popular is probably wxWindows.

    The nice thing about all three is that they are cross-platform, there are Windows implementations for them as well.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    As your name is C++.prog.newbie I'd also like to point you to Gtkmm, which is Gtk's offical C++ language binding.

    I'm not sure if all of the main distros have it already included in their package tree, but none the less it is widely accepted as the offical gtk c++ binding. I'm using it on a gentoo box, but it's also installed on my secondary PC, so it's also available for Fedora Core/Redhat.

    Code:
    #include <gtkmm.h>
    
    int main(int argc, char *argv[])
    {
        Gtk::Main kit(argc, argv);
    
        Gtk::Window window;
    
        Gtk::Main::run(window);
        
        return 0;
    }
    That is a window in Gtkmm. Of course all the standard c++ mechanics are in place, so you can derive your own windows, buttons etc. Gtkmm comes with libSigC++, so callbacks to class methods are possible. No more messy code

    Website is gtkmm.org. It might take some time to set it up on your system, but I found it well worth the time (that is *if* you want to code in C++ as your name indicates )
    [code]

    your code here....

    [/code]

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    heres the thing i didnt have a hard time learning C but with c++ the pointer and classes they really messed me up... i read online tutorials and read c++ for dummies and learn c++ in 21 days i just dont get classes and pointers. i know what there for i know why people implement them i just cant seem to remember how or were to use em. oh and when you use "::" int Gtk::Window window; thats like a pointer inside a class isnt it? so as for now i only really know basic c++

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Gtk::Window means the Windows class in the Gtk namespace - have you learned namespaces?


    It's hard to tell you about pointers and classes in a single post. Maybe this will help you. Use Mozilla or Opera to read this page, it won't show in IE:
    http://stud3.tuwien.ac.at/~e0226430/tutorial/oop.xml

    As for pointers, they are harder. Search the C and C++ forums or go to the FAQ, this question has been asked.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 04:15 AM
  3. Linux API functions
    By Micko in forum Linux Programming
    Replies: 3
    Last Post: 07-01-2004, 03:39 PM
  4. Linux? Windows Xp?
    By VooDoo in forum Linux Programming
    Replies: 15
    Last Post: 07-31-2002, 08:18 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 08:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21