【发布时间】:2021-02-04 01:30:02
【问题描述】:
我正在学习来自here 的 X11 编程教程。该页面提供了 2 个可用于编译基于 XCB 的程序的命令:
gcc -Wall prog.c -o prog `pkg-config --cflags --libs xcb`
和
gcc -Wall prog.c -lxcb
现在,我都试过了。第一个说gcc: error: unrecognized command-line option ‘--cflags’。显然这是一个与 shell 相关的问题(正如我所见 here)。所以我尝试了bash。这给出了一个不同的错误:
/usr/bin/ld: /tmp/ccnURTF3.o: in function `useXlib':
example.c:(.text+0xd6): undefined reference to `XInternAtom'
/usr/bin/ld: /tmp/ccnURTF3.o: in function `useXlibProperly':
example.c:(.text+0x163): undefined reference to `XInternAtoms'
/usr/bin/ld: /tmp/ccnURTF3.o: in function `main':
example.c:(.text+0x4b1): undefined reference to `XOpenDisplay'
/usr/bin/ld: example.c:(.text+0x559): undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
这与我使用gcc -Wall prog.c -lxcb 得到的相同。所以我猜bash 解决了这个问题,但有 2 个。在 Atom 中,当你将鼠标悬停在一个函数上时,它会显示它来自哪个标题。但是在这个我什么都没得到。
提前致谢
【问题讨论】:
-
pkg-config --cflags --libs xcb的结果是什么? -
@KamilCuk 对此很抱歉
-
@Gerhardh 我以前试过。它说
-lxcb。我认为它的意思是添加一个-lxcb标志而不是整个东西。但这也行不通。顺便说一句,这是一个错字