You are not logged in.
I'm trying to get myself familiar with X C Binding. extra/libxcb, extra/xcb-proto, extra/xcb-util and base-devel are installed.
When compiling a C++ script that makes use of functions declared in /usr/include/xcb/xcb.h, like xcb_connect(), the compiler complains about an undefined reference to xcb_connect(). Indeed, all such functions are only declared in xcb.h. They are defined in a file called xcb_util.c, but there is no such file on my system. Is it in some package or should I just download and dump it into /usr/include/?
Thanks in advance.
Last edited by Moshanator (2010-08-03 14:17:22)
Offline
Oh, silly me, trying to use a C binding in C++. Never mind.
Offline
You know it's possible, right? Just put
extern "C" {
#include <xcb.h>
...
}
"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page
Offline
So that's how you mix C++ and C. Thanks.
About the xcb_utils.c file, it's halfway compiled (is that the term? I have to link to it when calling gcc) and I'm not sure how C++ would work with that. Well, it probably would somehow, but I have no problem with using C for the task. Things are easier if done how they're supposed to, I'll just use C when learning a C library.
Offline
xcb_utils.c should have been compiled fully, but it doesn't create an actual program, rather a library (/usr/lib/libxcb.{a,so}). To link against it I would recommend using pkg-config. For example:
gcc *.c -o program $(pkg-config --cflags --libs xcb)
There are lots of other xcb libraries, so do an ls /usr/lib/pkgconfig/xcb* to find them.
If you don't need C++ for any other reason, then using C is the best bet I guess. You might also want to use C++ but without classes etc, which means you can avoid some annoying parts of C like having to declare everything at the top of a block.
"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page
Offline
...a library (/usr/lib/libxcb.{a,so}). To link against it...
Yeah, that's what I intended to mean. It's compiled, but it's not an application. pkg-config is what I'm using.
Gotta take a day or two and lurk here just to get my terminology right.
Offline
Please add [SOLVED] to your topic title instead of [INVALID]. This kind of custom prefixes only confuses people. You had a problem with did not turn out to be the one you expected, but it's solved nonetheless .
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline