ftylitak / qzxing

Qt/QML wrapper library for the ZXing library. 1D/2D barcode image processing library
Apache License 2.0
621 stars 340 forks source link

compiling example QZXingLive : application.cpp:(.text+0x234): undefined reference to `NativeHelpers::application_p_' #234

Open lycaon-qc opened 1 year ago

lycaon-qc commented 1 year ago

Hi,

I was able to use QZXing on a Ubuntu 20.04.6 LTS and decode various type of printed barcode (e.g. EAN 13, QR-code, data matrix code) using the webcam of my laptop (i.e. Chicony USB 2.0 webcam). The QZXing worked well, and I didn't have an issue during installation.

I was also able to compile and run the following examples provided in "[...]/qzxing-master/examples" : QZXingDragNDropTest and BarcodeEncoder. However, for QZXingLive, although I was able to run qmake, running make failed and gave the following error message:

usr/bin/ld: application.o: in function 'Application::Application()': application.cpp:(.text+0x234): undefined reference to 'NativeHelpers::applicationp' collect2: error: ld returned 1 exit status make: *** [Makefile:753: QZXingLive] Error 1

I looked in the issues here https://github.com/ftylitak/qzxing/issues and elsewhere, but I have not seen that someone had a similar issue previously when compiling QZXingLive.

I have not modified anything in "[...]/qzxing-master/examples/QZXingLive", except of course running qmake and make.

Does anyone out there did came across this problem and was able to fix it?

I am using a Ubuntu 20.04.6 LTS, the C++ compiler is GNU g++ 4:9.3.0-1ubuntu2 amd64, and the QMake version is 3.1 using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu. Let me know if additional information would be helpful.

1nvoker commented 6 months ago

https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/examples/QZXingLive/QZXingLive.pro#L35 https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/examples/QZXingLive/QZXingLive.pro#L36 https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/examples/QZXingLive/QZXingLive.pro#L37 https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/examples/QZXingLive/QZXingLive.pro#L38 https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/examples/QZXingLive/QZXingLive.pro#L39

你好,我也遇到了同样的问题,我是这样解决的。QZXingLive.pro 中35行至39行,条件性(目标为android 并且qt版本小于6.2)地包含了native.h和native.cpp。由于你编译的目标是linux,navtive.h,navtive.cpp没有包含在编译列表中,所以编译器找不到。将这两个文件加到HEADERS和SOURCES,就可以编译通过了。像这样

Hello, I also encountered the same problem, and this is how I solved it. QZXingLive.pro includes native. h and native. cpp conditionally (target is Android and qt version less than 6.2) from lines 35 to 39. Since the target you are compiling is Linux, navtive. h, and navtive. cpp are not included in the compilation list, the compiler cannot find them. Add these two files to HEADERS and SOURCES to compile them successfully. As follows

17 HEADERS += \ 18 application.h\ 19 native.h

20 SOURCES += main.cpp \ 21 application.cpp\ 22 native.cpp