简体   繁体   English

Linux/CUPS Qt 打印示例

[英]Linux/CUPS Qt printing example

I need to use the CUPS API in Qt to detect and install printers.我需要使用 Qt 中的 CUPS API 来检测和安装打印机。 The problem is I can't seem to make Qt detect the cups.h header file.问题是我似乎无法让 Qt 检测到 cups.h 头文件。 So far I tried (both with <> and ""):到目前为止,我尝试过(同时使用 <> 和 ""):

#include <cups/cups.h>

and

#include </usr/local/include/cups/cups.h>

In the .pro file I also tried adding:在 .pro 文件中,我还尝试添加:

INCLUDEPATH += /usr/local/include/cups

Each time I get "cups/cups.h: no such file or directory".每次我得到“cups/cups.h:没有这样的文件或目录”。 So can anybody provide a minimal example or a HOWTO that shows how to include and use CUPS in a Qt application.那么任何人都可以提供一个最小的例子或一个 HOWTO 来展示如何在 Qt 应用程序中包含和使用 CUPS。

Thanks!谢谢!

PS: I'am not sure if it's relevant, but I probably should add that I cross compiled Qt for the raspberry Pi. PS:我不确定它是否相关,但我可能应该补充一点,我为树莓派交叉编译了 Qt。

Install the "libcups2-dev" libraries.安装“libcups2-dev”库。

 sudo apt-get install libcups2-dev

then search for the library file然后搜索库文件

find / -type f -name "*.a"

you will get the response with all .a library files with the location您将获得所有带有位置的 .a 库文件的响应

find "libcups.a" file from the list.从列表中找到“libcups.a”文件。

example : /home/Desktop/cups-1.7.5/cups/libcups.a

Add the destination file path in your Qt .pro project file在 Qt .pro 项目文件中添加目标文件路径

LIBS += "../release/build/arm926/libcups.a"

LIBS += \\ /usr/lib/x86_64-linux-gnu/libcups.a LIBS + = \\ /usr/lib/x86_64-linux-gnu/libcups.a

Get error :-1: error: /usr/lib/x86_64-linux-gnu/libcups.a(file.o): undefined reference to symbol 'inflateEnd' 获取错误:-1:错误:/usr/lib/x86_64-linux-gnu/libcups.a(file.o):对符号'inflateEnd'的未定义引用

Please advice someone 请告诉别人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM