Re: want to compile an example code.
Alan Coopersmith <[email protected]> Mon, 5 Oct 2020 11:58:00 -0700
| Newsgroups | gmane.comp.freedesktop.xcb |
|---|---|
| Message-ID | <[email protected]> |
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- [email protected] Oracle Solaris Engineering - 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/xcb.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@NomadBSD ~/programmieren> ls > barchart.c include stdlibh.txt* includestdlibh.c Motif/ > windowexample.c xcbsample.c > nomad@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@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@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@NomadBSD ~/programmieren [1]> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > don't know why theese errors appear in that small code example. > > > > *Von:* Alan Coopersmith <[email protected]> > *Gesendet:* 04.10.2020 22:55 > *An:* Hans Schüren <[email protected]>,<[email protected]> > *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@NomadBSD ~/programmieren> gcc -Wall xcbsample.c -o xcbsample pkg-config > > --cflags --libs xcb > > fish: Unknown command: gcc > > nomad@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- [email protected] <mailto:[email protected]> > Oracle Solaris Engineering - https://blogs.oracle.com/alanc > <https://blogs.oracle.com/alanc> > _______________________________________________ > Xcb mailing list > [email protected] <mailto:[email protected]> > https://lists.freedesktop.org/mailman/listinfo/xcb > <https://lists.freedesktop.org/mailman/listinfo/xcb> _______________________________________________ Xcb mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/xcb