Code: Select all
make "CFLAGS=$(pkg-config --cflags --libs xcb xcb-randr)" bspwmxzoomrule
cc -lxcb -lxcb-randr bspwmxzoomrule.c -o bspwmxzoomrule
/usr/bin/ld: /tmp/ccFprU6F.o: in function `main':
bspwmxzoomrule.c:(.text+0xd7): undefined reference to `xcb_connect'
/usr/bin/ld: bspwmxzoomrule.c:(.text+0xe7): undefined reference to `xcb_connection_has_error'
/usr/bin/ld: bspwmxzoomrule.c:(.text+0x147): undefined reference to `xcb_get_property'
/usr/bin/ld: bspwmxzoomrule.c:(.text+0x164): undefined reference to `xcb_get_property_reply'
/usr/bin/ld: bspwmxzoomrule.c:(.text+0x1ac): undefined reference to `xcb_get_property_value_length'
/usr/bin/ld: bspwmxzoomrule.c:(.text+0x1c8): undefined reference to `xcb_get_property_value'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: bspwmxzoomrule] Error 1
Code: Select all
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xcb/xproto.h>
/* make "CFLAGS=$(pkg-config --cflags --libs xcb)" bspwmxzoomrule
cc -lxcb bspwmxzoomrule.c -o bspwmxzoomrule
*/
int main(const int argc, const char *const argv[])
{
if (argc < 2) {
if (fputs("No arguments given.\n", stderr) == EOF)
perror("fputs");
return EXIT_FAILURE;
}
char *end;
const union {
unsigned long as_ulong;
xcb_window_t as_xcb_window_t;
} wid = {
.as_ulong = strtoul(argv[1], &end, 0),
};
if (wid.as_ulong == ULONG_MAX) {
perror("strtoul");
return EXIT_FAILURE;
}
if (*end != '\0' || wid.as_xcb_window_t == XCB_NONE) {
if (fputs("Invalid argument.\n", stderr) == EOF)
perror("fputs");
return EXIT_FAILURE;
}
xcb_connection_t *const xcb = xcb_connect(NULL, NULL);
if (xcb_connection_has_error(xcb)) {
if (fputs("xcb_connect() failed.\n", stderr) == EOF)
perror("fputs");
return EXIT_FAILURE;
}
static const char xzoom_str[] = "xzoom";
const xcb_get_property_cookie_t cookie =
xcb_get_property(xcb, 0, wid.as_xcb_window_t,
XCB_ATOM_WM_ICON_NAME, XCB_ATOM_STRING, 0,
sizeof xzoom_str
? 1 + (sizeof xzoom_str - 1) / 4
: 0);
xcb_get_property_reply_t *const reply =
xcb_get_property_reply(xcb, cookie, NULL);
if (reply == NULL) {
if (EOF == fputs("xcb_get_property(WM_ICON_NAME) failed.\n",
stderr)) {
perror("fputs");
}
return EXIT_FAILURE;
}
const int length = xcb_get_property_value_length(reply);
if (length != sizeof xzoom_str - 1)
return EXIT_FAILURE;
const char *const value = xcb_get_property_value(reply);
if (strncmp(value, xzoom_str, sizeof xzoom_str - 1) != 0)
return EXIT_FAILURE;
free(reply);
if (puts("state=floating sticky=on") == EOF) {
perror("puts");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Is this a Debian 11 problem?