[Xcb] want to compile an example code.

Alan Coopersmith alan.coopersmith at oracle.com
Mon Oct 5 20:21:43 UTC 2020


The program xcb has nothing to do with the xcb library, and there is no
point in running it when trying to compile xcb programs.

The shell commands given should be putting the output of that command in
place on the command line when run so that the compiler is run as:

cc -Wall windowexample.c -o  windowexample \
   -I/usr/local/include   -pthread -L/usr/local/lib -lxcb

using the example from your NomadBSD system.  If that's not happening,
that's a problem with your shell or OS, and not something I can help
you fix.  Try a NomadBSD group instead.

	-Alan Coopersmith-               alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - https://blogs.oracle.com/alanc

On 10/5/20 12:23 PM, Hans Schüren wrote:
> hello,
> i have two computers with bsd.
> 
> NomadBSD 64bit says :  -I/usr/local/include   -pthread -L/usr/local/lib -lxcb
>                                           when i type here only  xcb ,  some 
> errors appears.
> 
> Freebsd 12.1 32bit says : Command not found.
>                                           for my surprise if i type only xcb  a 
> little GUI appears.
> 
> *Von:* Alan Coopersmith <alan.coopersmith at oracle.com>
> *Gesendet:* 05.10.2020 21:00
> *An:* Hans Schüren <Hans-Schueren at directbox.com>
> *Kopie:* XCB List <xcb at lists.freedesktop.org>
> *Betreff:* Re: AW: Re: [Xcb] want to compile an example code.
> That program compiles fine for me here.
> 
> What does the pkg-config command print if you just run:
> pkg-config --cflags --libs xcb
> 
> For me, it prints -lxcb, which should cause the compiler to link with the XCB
> library that defines those functions.
> 
> -Alan Coopersmith- alan.coopersmith at oracle.com <mailto:alan.coopersmith at oracle.com>
> Oracle Solaris Engineering - https://blogs.oracle.com/alanc 
> <https://blogs.oracle.com/alanc>
> 
> On 10/5/20 6:23 AM, Hans Schüren wrote:
>  > Thank you Alan ,  i have tried it.
>  >
>  > Please look at this session.
>  > I have chosen the very simple example from the XCB Manual :    could not stop
>  > additional compiling errors.
>  >
>  > =================================================================================
>  >
>  > #include <unistd.h> /* pause() */
>  >
>  > #include <xcb cb.h="">
>  >
>  > int
>  > main ()
>  > {
>  > xcb_connection_t *c;
>  > xcb_screen_t *screen;
>  > xcb_window_t win;
>  >
>  > /* Open the connection to the X server */
>  > c = xcb_connect (NULL, NULL);
>  >
>  > /* Get the first screen */
>  > screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
>  >
>  > /* Ask for our window's Id */
>  > win = xcb_generate_id(c);
>  >
>  > /* Create the window */
>  > xcb_create_window (c, /* Connection */
>  > XCB_COPY_FROM_PARENT, /* depth (same as root)*/
>  > win, /* window Id */
>  > screen->root, /* parent window */
>  > 0, 0, /* x, y */
>  > 150, 150, /* width, height */
>  > 10, /* border_width */
>  > XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
>  > screen->root_visual, /* visual */
>  > 0, NULL); /* masks, not used yet */
>  >
>  > /* Map the window on the screen */
>  > xcb_map_window (c, win);
>  >
>  > /* Make sure commands are sent before we pause, so window is shown */
>  > xcb_flush (c);
>  >
>  > pause (); /* hold client until Ctrl-C */
>  >
>  > return 0;
>  > }
>  >
>  > =================================================================================
>  >
>  > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  > nomad at NomadBSD ~/programmieren> ls
>  > barchart.c           include stdlibh.txt* includestdlibh.c     Motif/
>  >    windowexample.c      xcbsample.c
>  > nomad at NomadBSD ~/programmieren> cc -Wall windowexample.c -o  windowexample
>  > $(pkg-config --cflags --libs xcb) -I/usr/local/include/
>  > fish: $(...) is not supported. In fish, please use '(pkg-config)'.
>  > cc -Wall windowexample.c -o  windowexample $(pkg-config --cflags --libs xcb)
>  > -I/usr/local/include/
>  >                                            ^
>  > nomad at NomadBSD ~/programmieren> cc -Wall windowexample.c -o  windowexample
>  > '(pkg-config --cflags --libs xcb)' -I/usr/local/include/
>  > cc: error: no such file or directory: '(pkg-config --cflags --libs xcb)'
>  > nomad at NomadBSD ~/programmieren [1]> cc -Wall windowexample.c -o  windowexample
>  > (pkg-config --cflags --libs xcb) -I/usr/local/include/
>  > ld: error: undefined symbol: xcb_connect
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_get_setup
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_setup_roots_iterator
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_generate_id
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_create_window
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_map_window
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > ld: error: undefined symbol: xcb_flush
>  > >>> referenced by windowexample.c
>  > >>>               /tmp/windowexample-2f744c.o:(main)
>  > cc: error: linker command failed with exit code 1 (use -v to see invocation)
>  > nomad at NomadBSD ~/programmieren [1]>
>  > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  >
>  > don't know why theese errors appear in that small code example.
>  >
>  >
>  >
>  > *Von:* Alan Coopersmith <alan.coopersmith at oracle.com 
> <mailto:alan.coopersmith at oracle.com>>
>  > *Gesendet:* 04.10.2020 22:55
>  > *An:* Hans Schüren <hans-schueren at directbox.com 
> <mailto:hans-schueren at directbox.com>>,<xcb at lists.freedesktop.org 
> <mailto:xcb at lists.freedesktop.org>>
>  > *Betreff:* Re: [Xcb] want to compile an example code.
>  > On 10/4/20 12:38 PM, Hans Schüren wrote:
>  > > Hello,
>  > >
>  > > i want to compile a sample code from the XCB manual.
>  > >
>  > > There are the following errors. What can i do ?
>  > >
>  > > I use FreeBSD and have XCB installed.
>  > >
>  > > barchart.c   Motif/       xcbsample.c
>  > > nomad at NomadBSD ~/programmieren> gcc -Wall xcbsample.c -o xcbsample  pkg-config
>  > > --cflags --libs xcb
>  > > fish: Unknown command: gcc
>  > > nomad at NomadBSD ~/programmieren [127]> cc -Wall xcbsample.c -o xcbsample
>  > > pkg-config --cflags --libs xcb
>  > > cc: error: unsupported option '--cflags'
>  > > cc: error: unsupported option '--libs'
>  > > cc: error: no such file or directory: 'pkg-config'
>  > > cc: error: no such file or directory: 'xcb'
>  >
>  > You need to put $( ) or ` ` around the pkg-config command so that the
>  > output of the pkg-config command is used as flags to the compiler:
>  >
>  > cc -Wall xcbsample.c -o xcbsample $(pkg-config --cflags --libs xcb)
>  >
>  > or
>  >
>  > cc -Wall xcbsample.c -o xcbsample `pkg-config --cflags --libs xcb`
>  >
>  > (It depends on what shell you use - the first is preferred for most shells,
>  > but some old shells like csh may require the second form.)
>  >
>  > --
>  > -Alan Coopersmith- alan.coopersmith at oracle.com 
> <mailto:alan.coopersmith at oracle.com> <mailto:alan.coopersmith at oracle.com 
> <mailto:alan.coopersmith at oracle.com>>
>  > Oracle Solaris Engineering - https://blogs.oracle.com/alanc 
> <https://blogs.oracle.com/alanc>
>  > <https <https>: blogs.oracle.com/alanc="">
>  > _______________________________________________
>  > Xcb mailing list
>  > Xcb at lists.freedesktop.org <mailto:Xcb at lists.freedesktop.org> 
> <mailto:xcb at lists.freedesktop.org <mailto:xcb at lists.freedesktop.org>>
>  > https://lists.freedesktop.org/mailman/listinfo/xcb 
> <https://lists.freedesktop.org/mailman/listinfo/xcb>
>  > <https <https>: lists.freedesktop.org/mailman/listinfo/xcb="">
> 
> 
> </https:></mailto <https:></mailto>:xcb at lists.freedesktop.org 
> <mailto:xcb at lists.freedesktop.org>></https:></mailto 
> <https:></mailto>:alan.coopersmith at oracle.com 
> <mailto:alan.coopersmith at oracle.com>></xcb at lists.freedesktop.org 
> <mailto:/xcb at lists.freedesktop.org>></hans-schueren at directbox.com 
> <mailto:/hans-schueren at directbox.com>></alan.coopersmith at oracle.com 
> <mailto:/alan.coopersmith at oracle.com>></xcb></unistd.h>



More information about the Xcb mailing list