我正在尝试学习 CUPS API 开发。为此,我在 ubuntu 16.04 中安装了 CUPS 2.1.3-4
。
当我尝试执行他们的初始教程时,我收到以下错误。
||=== Build: Debug in cupsfirst (compiler: GNU GCC Compiler) ===| obj/Debug/main.o||In function
main':| /home/xxxx/CUPS/cupsfirst/main.c|8|undefined reference to
cupsGetDests'| ||error: ld returned 1 exit status| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
这是我最初的计划。
#include <stdio.h>
#include <cups/cups.h>
int main(void)
{
int i;
cups_dest_t *dests, *dest;
int num_dests = cupsGetDests(&dests);
for (i = num_dests, dest = dests; i > 0; i --, dest ++)
{
if (dest->instance)
printf("%s/%s\n", dest->name, dest->instance);
else
puts(dest->name);
}
return (0);
}
最佳答案
您需要安装 CUPS 库、开发包(我想您已经有了)
apt install libcups2 libcups2-dev
要编译然后链接,请包含cups2库
gcc myprog.c -o myprog -lcups
关于CUPS 对 cupsGetDests() 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47451064/