LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2005, 03:21 AM   #1
a1ex_007
LQ Newbie
 
Registered: Mar 2005
Location: Imphal
Distribution: Fedora Core 3 x86_64
Posts: 26

Rep: Reputation: 15
X windows programming how do i start


I have been trying to start working on X windows programming, but have been facing a problem at the beginning. can anybody help ? I could get the libraries linked

here is the first code that i tried

graphics.c

#include<X11/Intrinsic.h>
#include<Xm/Xm.h>
#include<Xm/BulletinB.h>
#include<Xm/PushB.h>

Display *display;
XtAppContext context;
Widget toplevel,manager,exit_button;


int ExitCallback( Widget w, Xt_pointer client_data, XtPointer call_data );

main(int argc, char **argv){

XtToolkitInitialize();
context = XtOpenDisplay( context, "", "hello", "Hello", NULL, 0, &argc, &argv );

toplevel = XtAppCreateShell( "hello", "Hello", applicationShellWidgetClass, display, NULL,0 );

manager = XtCreateWidget( "manager", XmBulletinBoardWidgetClass, toplevel, NULL, 0 );

exit_button = XtCreateWidget( "Exit Button", XmPushButtonWidgetClass, manager, NULL,0);

XtAddCallback( exit_button, XmNactivateCallback, ExitCallback, NULL);

XtManageChild(exit_button);
XtManageChild(manager);
XtRealizeWidget(toplevel);

XtAppMainLoop(context);

}



int ExitCallback(Widget w, Xt_pointer client_data, XtPointer call_data){
exit(0);
}



and it would not compile, the error mesg ----

graphics.c:11: error: syntax error before "Xt_pointer"
graphics.c: In function `main':
graphics.c:16: warning: passing arg 8 of `XtOpenDisplay' from incompatible pointer type
graphics.c:16: warning: assignment from incompatible pointer type
graphics.c:20: error: syntax error before "XmBulletinBoardWidgetClass"
graphics.c:22: error: syntax error before "XmPushButtonWidgetClass"
graphics.c:24: warning: passing arg 3 of `XtAddCallback' from incompatible pointer type
graphics.c: At top level:
graphics.c:36: error: syntax error before "Xt_pointer"
 
Old 03-10-2005, 08:55 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I made some modifications in your code :
Code:
#include<X11/Intrinsic.h>
#include<Xm/Xm.h>
#include<Xm/BulletinB.h>
#include<Xm/PushB.h>

Display *display;
XtAppContext context;
Widget toplevel,manager,exit_button;


void ExitCallback( Widget w, XtPointer client_data, XtPointer call_data );

int main(int argc, char **argv){

    XtToolkitInitialize();
    context = XtCreateApplicationContext();
    display = XtOpenDisplay( context, "", "hello", "Hello", NULL, 0, &argc, argv );

    toplevel = XtAppCreateShell( "hello", "Hello", applicationShellWidgetClass, display, NULL,0 );

    manager = XtCreateWidget( "manager", xmBulletinBoardWidgetClass, toplevel, NULL, 0 );

    exit_button = XtCreateWidget( "Exit Button", xmPushButtonWidgetClass, manager, NULL,0);

    XtAddCallback( exit_button,  XmNactivateCallback,  ExitCallback, NULL);

    XtManageChild(exit_button);
    XtManageChild(manager);
    XtRealizeWidget(toplevel);

    XtAppMainLoop(context);
    return 0;
}

void ExitCallback(Widget w, XtPointer client_data, XtPointer call_data){
    exit(0);
}
compile with something like :
gcc -o graphics graphics.c -L/usr/X11R6/lib -lXm -lXt -lX11 -I/usr/X11R6/include
 
Old 03-11-2005, 12:15 AM   #3
a1ex_007
LQ Newbie
 
Registered: Mar 2005
Location: Imphal
Distribution: Fedora Core 3 x86_64
Posts: 26

Original Poster
Rep: Reputation: 15
i tried the code but its still give me an error ..........

[root@buzz ~]# gcc -o graphics graphics.c -L/usr/X11R6/lib -lXm -lXt -lX11 -I/usr/X11R6/include

graphics.c:10: error: syntax error before "Xt_pointer"
graphics.c: In function `main':
graphics.c:18: warning: passing arg 8 of `XtOpenDisplay' from incompatible pointer type
graphics.c:26: warning: passing arg 3 of `XtAddCallback' from incompatible pointer type
 
Old 03-11-2005, 07:53 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Just copy and paste my modified code and try to compile it as I already did the changes
to fix those errors
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to start Linux programming cliff76 Linux - Newbie 2 06-30-2005 02:24 PM
How to start Assembly Programming ? indian Programming 17 04-19-2005 10:51 PM
When and why did you start programming? BBB Programming 33 01-17-2005 04:29 PM
how and where to start programming in linux? ninadb Programming 12 05-10-2004 12:09 PM
I want to start programming, need help though... Eits0 Programming 8 05-16-2002 08:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration