paolostivanin / OTPClient

Highly secure and easy to use OTP client written in C/GTK3 that supports both TOTP and HOTP
GNU General Public License v3.0
482 stars 47 forks source link

error: implicit declaration of function ‘zbar_fourcc’ #310

Closed JohnCC330 closed 1 year ago

JohnCC330 commented 1 year ago

On 'manual' compilation, I get the following:

...
[ 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

This seems to be an internal (to otpclient) issue... If I can find the time, I'll try and find the problem.

paolostivanin commented 1 year ago

Hello, this is not an OTPClient issue. You need to install all the needed devel packages (you are currently missing the one for zbar).

Have a look at https://github.com/paolostivanin/OTPClient/blob/0da71785ad483c6607dfd95fce7d8014987f2c38/.circleci/config.yml#L18 for an example for Ubuntu.

JohnCC330 commented 1 year ago

Sorry, I should have mentioned I'm using Slackware - all .h headers are installed by default. I also compiled zbar myself, so these headers are there too. Thanks for the quick reply though!

JohnCC330 commented 1 year ago

Checking:

So, I compiled again, with VERBOSE=1, and captured the compile command for qrcode-parser.c: (I split the output for readability)

Building C object CMakeFiles/OTPClient.dir/src/qrcode-parser.c.o
/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

Note that the command is not including zbar? I'm not familiar with CMAKE (I was hoping to skip CMAKE to Meson...

paolostivanin commented 1 year ago

What version of zbar are you using?

It has to be something misconfigured on your system, because the package is compiling fine on Ubuntu, Fedora, Debian, openSUSE, Archlinux and NixOS.

I'm not familiar with Slackware, so I can't really help here, sorry.

JohnCC330 commented 1 year ago

The biggest difference is that libraries are installed in /usr/lib64. As usual, include files are in /usr/include. I find it very strange that, though pkg-config reports correctly the include file's name, it does not appear in the compile command line.

Older versions of the CMAKE scripts had troubles working with library path /usr/lib64.

zbar is version 0.23.90.

paolostivanin commented 1 year ago

Also on most other distros libs are installed under /usr/lib64, so that's not the issue here :thinking:

paolostivanin commented 1 year ago

What GCC and cmake version are you using?

JohnCC330 commented 1 year ago

cmake version 3.25.1 gcc (GCC) 12.2.0

JohnCC330 commented 1 year ago

Hi Paolo!

As this was probably a linking problem, I asked the same question on Stackoverflow, and they suggested that there might be an older version of zbar.h lying around. Sure enough, in /usr/local/include was a zbar.h (from 2014!) - The actual library was not there, but the .h was enough to throw the compiler off course. Thanks!

There was just one confusion: When creating a new database, Gnome keyring prompted for a password - which had to be the user's password, not the database password...