You are not logged in.

#1 2010-07-31 14:17:56

Moshanator
Member
Registered: 2010-07-31
Posts: 4

[SOLVED]xcb_util.c is nowhere to be found

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

#2 2010-07-31 14:59:35

Moshanator
Member
Registered: 2010-07-31
Posts: 4

Re: [SOLVED]xcb_util.c is nowhere to be found

Oh, silly me, trying to use a C binding in C++. Never mind.

Offline

#3 2010-08-02 08:50:24

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: [SOLVED]xcb_util.c is nowhere to be found

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

#4 2010-08-02 10:06:27

Moshanator
Member
Registered: 2010-07-31
Posts: 4

Re: [SOLVED]xcb_util.c is nowhere to be found

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

#5 2010-08-02 23:57:15

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: [SOLVED]xcb_util.c is nowhere to be found

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

#6 2010-08-03 09:13:26

Moshanator
Member
Registered: 2010-07-31
Posts: 4

Re: [SOLVED]xcb_util.c is nowhere to be found

PirateJonno wrote:

...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

#7 2010-08-03 11:38:27

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [SOLVED]xcb_util.c is nowhere to be found

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 wink.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

Board footer

Powered by FluxBB