编译 OTPclient,函数“zbar_fourcc”的隐式声明

Compiling OTPclient, implicit declaration of function ‘zbar_fourcc’

提问人:jcoppens 提问时间:10/3/2023 更新时间:10/3/2023 访问量:17

问:

在“手动”编译(即 mkdir build; cmake ..)中,我得到以下内容:

[ 25%] Building C object CMakeFiles/OTPClient.dir/src/parse-data.c.o
[ 27%] Building C object CMakeFiles/OTPClient.dir/src/parse-uri.c.o
[ 29%] Building C object CMakeFiles/OTPClient.dir/src/password-cb.c.o
[ 30%] Building C object CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o
/tmp/SBo/OTPClient-master/src/qrcode-parser.c: In function ‘parse_qrcode’:
/tmp/SBo/OTPClient-master/src/qrcode-parser.c:36:35: error: implicit declaration of function ‘zbar_fourcc’ [-Werror=implicit-function-declaration]
   36 |     zbar_image_set_format (image, zbar_fourcc ('Y','8','0','0'));
      |                                   ^~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [CMakeFiles/OTPClient.dir/build.make:328: CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/OTPClient.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

检查:

  • zbar.h 中,其子目录 zbar 也在那里/usr/lib64
  • 它包含zbar_fourcc函数定义。
  • $ pkg-config --cflags --libs zbar返回值(请参阅下面的编译命令)-lzbar
  • zbar是版本 0.23.90
  • cmake版本 3.25.1
  • gcc (GCC)12.2.0
  • 我使用 Slackware64 15.0
  • 编译失败的 in 确实包含语句src/qrcode-parser.c#include <zbar.h>

使用 VERBOSE=1 进行编译,生成编译命令(格式化是我的):

/usr/bin/cc 
   -DGETTEXT_PACKAGE=\"OTPClient\" 
   -I/usr/local/src/internet/opt/OTPClient-master/build 
   -I/usr/include/gtk-3.0 
   -I/usr/include/at-spi2-atk/2.0 
   -I/usr/include/at-spi-2.0 
   -I/usr/include/dbus-1.0 
   -I/usr/lib64/dbus-1.0/include 
   -I/usr/include/gio-unix-2.0 
   -I/usr/include/cairo 
   -I/usr/include/pango-1.0 
   -I/usr/include/harfbuzz 
   -I/usr/include/fribidi 
   -I/usr/include/atk-1.0 
   -I/usr/include/pixman-1 
   -I/usr/include/libxml2 
   -I/usr/include/freetype2 
   -I/usr/include/gdk-pixbuf-2.0 
   -I/usr/include/libpng16 
   -I/usr/include/libmount 
   -I/usr/include/blkid 
   -I/usr/include/glib-2.0 
   -I/usr/lib64/glib-2.0/include 
   -I/usr/include/uuid 
   -I/usr/include/libsecret-1 
   -Wall 
   -Wextra -O2 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong -Wundef 
   -Wmissing-format-attribute -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code 
   -Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align 
   -Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare 
   -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pie -fPIE -DBUILD_GUI -DBUILD_CLI -std=gnu11 
   -MD -MT CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o -MF 
   CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o.d -o CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o 
   -c /usr/local/src/internet/opt/OTPClient-master/src/qrcode-parser.c

我很少使用 CMAKE,但对我来说,该命令不包含语句似乎很奇怪。-I/usr/include/zbar.h

有接受者吗?

C Linux GCC CMake

评论

1赞 Tsyvarev 10/3/2023
"zbar.h is in “ - 否,文件不在用于库的目录中。它很可能位于 .可能是其他一些包含目录包含文件,因此它被包含而不是标准目录。请参阅该问题进行调试,编译器包含了哪个确切的标头。/usr/lib64/usr/includezbar.h
0赞 jcoppens 10/3/2023
对不起,这是打字错误。当然,它在 中,包含零件的 zbar 目录也是如此。但是,正如你所说,我确实找到了一个旧副本(2014 年)在!奇怪的是,我删除了没有zbar.pc,现在编译成功了。谢谢!/usr/includezbar.husr/local/include/usr/local/lib64/pkgconfig/zbar.h

答: 暂无答案