Errors of 'Xlib.h' and 'Xutils.h' - X

This is a discussion on Errors of 'Xlib.h' and 'Xutils.h' - X ; Hi group, I am getting started with XWindow but I have a problem. I have a program p.cpp and I type this: c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp after, I get these errors: XOpenDisplay, reference not defined. X... (other functions of Xlib), ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Errors of 'Xlib.h' and 'Xutils.h'

  1. Errors of 'Xlib.h' and 'Xutils.h'

    Hi group,

    I am getting started with XWindow but I have a problem.

    I have a program p.cpp and I type this:

    c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp

    after, I get these errors:

    XOpenDisplay, reference not defined.
    X... (other functions of Xlib), reference not defined.

    I have included the files 'Xlib.h' and 'Xutils.h'.

    I have installed the XFree86-devel package.

    Somebody know how to fix it?

    thanks in advance.

    I am using Linux Redhat 9.0

  2. Re: Errors of 'Xlib.h' and 'Xutils.h'

    On 17 Sep 2004 07:24:56 -0700, Ariel Alonzo Medina V?zquez staggered
    into the Black Sun and said:
    > I am getting started with XWindow but I have a problem. I have a
    > program p.cpp and I type this:
    >
    > c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp


    Er. c++ ? The C++ compiler is usually referred to as g++, but it
    should be the same no matter what.

    > I get these errors:
    > XOpenDisplay, reference not defined.
    > X... (other functions of Xlib), reference not defined.
    > I have included the files 'Xlib.h' and 'Xutils.h'. I have installed
    > the XFree86-devel package. I am using Linux Redhat 9.0


    Your compiler command line is not correct. -l/usr/X11R6/include should
    be -I/usr/X11R6/include. l and I are very different and if your font
    doesn't make them easy to distinguish, you need to use a different font.
    You also need at least -lX11 , so that the compiler will -link with
    libX11.a . Maybe other -l options, depending on which X11 functions
    you're using. HTH,

    --
    Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
    Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
    http://www.brainbench.com / Hire me!
    -----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

  3. Re: Errors of 'Xlib.h' and 'Xutils.h'

    Dances With Crows wrote in message news:...
    > On 17 Sep 2004 07:24:56 -0700, Ariel Alonzo Medina V?zquez staggered
    > into the Black Sun and said:
    > > I am getting started with XWindow but I have a problem. I have a
    > > program p.cpp and I type this:
    > >
    > > c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp

    >
    > Er. c++ ? The C++ compiler is usually referred to as g++, but it
    > should be the same no matter what.
    >


    Really, c++ is the same that g++.

    > > I get these errors:
    > > XOpenDisplay, reference not defined.
    > > X... (other functions of Xlib), reference not defined.
    > > I have included the files 'Xlib.h' and 'Xutils.h'. I have installed
    > > the XFree86-devel package. I am using Linux Redhat 9.0

    >
    > Your compiler command line is not correct. -l/usr/X11R6/include should
    > be -I/usr/X11R6/include. l and I are very different and if your font
    > doesn't make them easy to distinguish, you need to use a different font.
    > You also need at least -lX11 , so that the compiler will -link with
    > libX11.a . Maybe other -l options, depending on which X11 functions
    > you're using. HTH,


    Thanks a lot, it is already compiled, but when I try to execute, this
    error appears: 'Violation of segment'. Could you help me?

    Thanks

  4. Re: Errors of 'Xlib.h' and 'Xutils.h'

    Ariel Alonzo Medina V?zquez wrote:
    > Dances With Crows wrote in message news:...
    >
    >>On 17 Sep 2004 07:24:56 -0700, Ariel Alonzo Medina V?zquez staggered
    >>into the Black Sun and said:
    >>
    >>>I am getting started with XWindow but I have a problem. I have a
    >>>program p.cpp and I type this:
    >>>
    >>>c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp

    >>
    >>Er. c++ ? The C++ compiler is usually referred to as g++, but it
    >>should be the same no matter what.
    >>

    >
    >
    > Really, c++ is the same that g++.
    >
    >
    >>>I get these errors:
    >>>XOpenDisplay, reference not defined.
    >>>X... (other functions of Xlib), reference not defined.
    >>>I have included the files 'Xlib.h' and 'Xutils.h'. I have installed
    >>>the XFree86-devel package. I am using Linux Redhat 9.0

    >>
    >>Your compiler command line is not correct. -l/usr/X11R6/include should
    >>be -I/usr/X11R6/include. l and I are very different and if your font
    >>doesn't make them easy to distinguish, you need to use a different font.
    >>You also need at least -lX11 , so that the compiler will -link with
    >>libX11.a . Maybe other -l options, depending on which X11 functions
    >>you're using. HTH,

    >
    >
    > Thanks a lot, it is already compiled, but when I try to execute, this
    > error appears: 'Violation of segment'. Could you help me?
    >


    You have a pointer pointing outside the memory you have in
    your use. Standard debugging problem - time to call gdb to duty.

    Tauno Voipio
    tauno voipio (at) iki fi


  5. Re: Errors of 'Xlib.h' and 'Xutils.h'

    Tauno Voipio wrote in message news:...
    > Ariel Alonzo Medina V?zquez wrote:
    > > Dances With Crows wrote in message news:...
    > >
    > >>On 17 Sep 2004 07:24:56 -0700, Ariel Alonzo Medina V?zquez staggered
    > >>into the Black Sun and said:
    > >>
    > >>>I am getting started with XWindow but I have a problem. I have a
    > >>>program p.cpp and I type this:
    > >>>
    > >>>c++ -l/usr/X11R6/include -L/usr/X11R6/lib p.cpp
    > >>
    > >>Er. c++ ? The C++ compiler is usually referred to as g++, but it
    > >>should be the same no matter what.
    > >>

    > >
    > >
    > > Really, c++ is the same that g++.
    > >
    > >
    > >>>I get these errors:
    > >>>XOpenDisplay, reference not defined.
    > >>>X... (other functions of Xlib), reference not defined.
    > >>>I have included the files 'Xlib.h' and 'Xutils.h'. I have installed
    > >>>the XFree86-devel package. I am using Linux Redhat 9.0
    > >>
    > >>Your compiler command line is not correct. -l/usr/X11R6/include should
    > >>be -I/usr/X11R6/include. l and I are very different and if your font
    > >>doesn't make them easy to distinguish, you need to use a different font.
    > >>You also need at least -lX11 , so that the compiler will -link with
    > >>libX11.a . Maybe other -l options, depending on which X11 functions
    > >>you're using. HTH,

    > >
    > >
    > > Thanks a lot, it is already compiled, but when I try to execute, this
    > > error appears: 'Violation of segment'. Could you help me?
    > >

    >
    > You have a pointer pointing outside the memory you have in
    > your use. Standard debugging problem - time to call gdb to duty.
    >
    > Tauno Voipio
    > tauno voipio (at) iki fi


    Thanks for replying,

    I have discovered the problem. XOpenDisplay is returning NULL and that
    causes the error when I call XCreateSimpleWindow with the returned
    value.

    I was calling XOpenDisplay with argument NULL and It did not work, but
    when I called that with argument "localhost.localdomain:0.0" it did.

    Is there any manner to fix it? I think to depend of machine's name is
    bad.

    Thanks.

    Ariel

  6. Re: Errors of 'Xlib.h' and 'Xutils.h'

    On 21 Sep 2004 05:54:24 -0700, Ariel Alonzo Medina V?zquez staggered
    into the Black Sun and said:
    > Tauno Voipio wrote
    >> Ariel Alonzo Medina V?zquez wrote:

    [ problems compiling an X program, now the X program compiles, but it
    won't execute. ]
    >> > Thanks a lot, it is already compiled, but when I try to execute,
    >> > this error appears: 'Violation of segment'. Could you help me?

    >> You have a pointer pointing outside the memory you have in
    >> your use. Standard debugging problem - time to call gdb to duty.

    >
    > I have discovered the problem. XOpenDisplay is returning NULL and that
    > causes the error when I call XCreateSimpleWindow with the returned
    > value.
    >
    > I was calling XOpenDisplay with argument NULL and It did not work, but
    > when I called that with argument "localhost.localdomain:0.0" it did.
    > Is there any manner to fix it? I think to depend of machine's name is
    > bad.


    So do this:

    char hostname[64],buff[64];
    Display my_display;

    gethostname(hostname,64);
    strcat(buff,":0");
    my_display=XOpenDisplay(buff);
    if(!my_display){
    barf("Dammit. Couldn't open display.\n");
    exit(1);
    }
    /* do something with my_display */

    --
    Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
    Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
    http://www.brainbench.com / Hire me!
    -----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

  7. Re: Errors of 'Xlib.h' and 'Xutils.h'

    On 21 Sep 2004 13:28:54 GMT, Dances With Crows staggered into the Black
    Sun and said:
    [snip]
    > char hostname[64],buff[64];
    > Display my_display;
    >
    > gethostname(hostname,64);
    > strcat(buff,":0");


    It's too early in the morning for coherent thought from me. I meant:

    snprintf(buff,64,"%s:0",hostname);

    /* that'll work, but if the machine has multiple displays, it'll be
    * locked to the first one. */

    --
    Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
    Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
    http://www.brainbench.com / Hire me!
    -----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

  8. Re: Errors of 'Xlib.h' and 'Xutils.h'

    Dances With Crows wrote in message news:...
    > On 21 Sep 2004 13:28:54 GMT, Dances With Crows staggered into the Black
    > Sun and said:
    > [snip]
    > > char hostname[64],buff[64];
    > > Display my_display;
    > >
    > > gethostname(hostname,64);
    > > strcat(buff,":0");

    >
    > It's too early in the morning for coherent thought from me. I meant:
    >
    > snprintf(buff,64,"%s:0",hostname);
    >
    > /* that'll work, but if the machine has multiple displays, it'll be
    > * locked to the first one. */



    Thanks a lot,

    Ariel

+ Reply to Thread