mchehab / zbar

ZBar is an open source software suite for reading bar codes from various sources, including webcams. As its development stopped in 2012, I took the task of keeping it updated with the V4L2 API. This is the main repository for it. There's a clone at at LinuxTV.org, and another one at gitlab.
https://linuxtv.org/downloads/zbar/
GNU Lesser General Public License v2.1
964 stars 202 forks source link

Failed to compile with Exception.h in Ubuntu 22.04 #254

Closed simk0024 closed 1 year ago

simk0024 commented 1 year ago

expected identifier before string constant and other errors are encountered while compile in Ubuntu 22.04. zbar was installed sudo apt install libzbar-dev libzbar0 any advice?

Errors:

/usr/include/zbar/Exception.h:76:5: error: expected identifier before string constant
   76 |     UnsupportedError (const void *obj)
      |     ^~~~~~~~~~~~~~~~
/usr/include/zbar/Exception.h:76:5: error: expected ‘,’ or ‘...’ before string constant
In file included from /usr/include/zbar.h:1644,
                 from /home/sg-atcoe-23761/ws_scannerbot/src/scanning_slh/scannerbot/include/scannerbot/zbar_scanner.hpp:3,
                 from /home/sg-atcoe-23761/ws_scannerbot/src/scanning_slh/scannerbot/include/scannerbot/scannerbot_node.hpp:17,
                 from /home/sg-atcoe-23761/ws_scannerbot/src/scanning_slh/scannerbot/src/scannerbot_node.cpp:1:
/usr/include/zbar/Exception.h: In member function ‘int zbar::UnsupportedError::Error(int)’:
/usr/include/zbar/Exception.h:77:11: error: only constructors take member initializers
   77 |         : Exception(obj)
      |           ^~~~~~~~~
/usr/include/zbar/Exception.h:77:21: error: ‘obj’ was not declared in this scope; did you mean ‘_obj’?
   77 |         : Exception(obj)
      |                     ^~~
      |                     _obj
In file included from /usr/local/include/ZXing/Result.h:14,
                 from /usr/local/include/ZXing/ReadBarcode.h:10,
                 from /home/sg-atcoe-23761/ws_scannerbot/src/scanning_slh/scannerbot/include/scannerbot/scannerbot_node.hpp:11,
                 from /home/sg-atcoe-23761/ws_scannerbot/src/scanning_slh/scannerbot/src/scannerbot_node.cpp:1:
/usr/include/zbar/Exception.h: In function ‘std::exception zbar::throw_exception(const void*)’:
/usr/include/zbar/Exception.h:166:15: error: ‘Error’ has not been declared
  166 |         throw UnsupportedError(obj);
      |               ^~~~~~~~~~~~~~~~
/usr/include/zbar/Exception.h:166:15: error: no matching function for call to ‘std::__cxx11::basic_string<char>::basic_string(const void*&)’
  166 |         throw UnsupportedError(obj);
      |               ^~~~~~~~~~~~~~~~
simk0024 commented 1 year ago

My bad, I was trying to compile a program which use ZBar and ZXing at the same times, which caused the conflict of some declaration and functions. Compilation works when I compile 2 libraries separately before used as dependencies in the main program.