Summary: | media-libs/opencv-3.1.0 - /usr/lib64/libtesseract.so.3: undefined reference to `clBuildProgram' | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Juergen Rose <rose> |
Component: | [OLD] Library | Assignee: | Amy Liffey <amynka> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | abulak, agrigo2001, dilfridge, dracwyrm, dschridde+gentoobugs, fcoiffie, gokturk, silvio.gerli |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 566920 | ||
Attachments: |
build.log
opencv-tesseract.patch tesseract-3.04.00-fix-link-with-opencl.patch opencv-tesseract-test.patch opencv_contrib-3.1.0-tesseract-opencl-test.patch |
Description
Juergen Rose
2016-01-25 07:56:29 UTC
Can you double check that app-text/tesseract is compiled with the "opencl" USE flag? (In reply to Gokturk Yuksek from comment #1) > Can you double check that app-text/tesseract is compiled with the "opencl" > USE flag? tesseract was compiled with the opencl USE flag and I compiled it just once more: root@caiman:/root(31)# date Tue Jan 26 08:18:43 CET 2016 root@caiman:/root(32)# emerge -pvD tesseract These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] app-text/tesseract-3.04.00-r3::gentoo USE="doc examples jpeg math opencl png scrollview tiff -osd -static-libs -training -webp" LINGUAS="de fr ru -ar -bg -ca -chr -cs -da -el -es -fi -he -hi -hu -id -it -jp -ko -lt -lv -nl -no -pl -pt -ro -sk -sl -sr -sv -th -tl -tr -uk -vi -zh_CN -zh_TW" 0 KiB Total: 1 package (1 reinstall), Size of downloads: 0 KiB root@caiman:/root(33)# emerge -v1 tesseract ... >>> Original instance of package unmerged safely. >>> app-text/tesseract-3.04.00-r3 merged. >>> Regenerating /etc/ld.so.cache... >>> Auto-cleaning packages... >>> No outdated packages were found on your system. ... root@caiman:/root(35)# MAKEOPTS=-j1 emerge -v1 opencv These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild U ] media-libs/opencv-3.1.0:0/3.0::gentoo [3.0.0:0/3.0::x-portage] USE="contrib doc eigen examples ffmpeg gdal%* gphoto2%* gstreamer gtk java jpeg jpeg2k opencl openexr opengl openmp png python qt5 threads tiff v4l vaapi%* vtk xine -cuda -ieee1394 (-ipp) -libav -pch -qt4 -testprograms -webp%" PYTHON_SINGLE_TARGET="python2_7 -python3_3 -python3_4" PYTHON_TARGETS="python2_7 python3_4 -python3_3" 0 KiB ... /usr/bin/x86_64-pc-linux-gnu-g++ -march=amdfam10 -O2 -pipe -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -Wl,-O1 -Wl,--as-needed CMakeFiles/example_text_cropped_word_recognition.dir/samples/cropped_word_recognition.cpp.o -o ../../bin/example_text_cropped_word_recognition -rdynamic ../../lib/libopencv_text.so.3.1.0 ../../lib/libopencv_features2d.so.3.1.0 ../../lib/libopencv_highgui.so.3.1.0 ../../lib/libopencv_flann.so.3.1.0 ../../lib/libopencv_ml.so.3.1.0 ../../lib/libopencv_videoio.so.3.1.0 ../../lib/libopencv_imgcodecs.so.3.1.0 ../../lib/libopencv_imgproc.so.3.1.0 ../../lib/libopencv_core.so.3.1.0 /usr/lib64/libtesseract.so.3: undefined reference to `clBuildProgram' ... The only packages, where I removed the opencl USE flag, is hwloc: root@caiman:/root(36)# grep opencl /etc/portage/package.use sys-apps/hwloc -opencl >=virtual/opencl-0-r4 abi_x86_32 root@caiman:/root(37)# BTW., mesa is selected as OpenCL implementation, ati-drivers are not installed: root@caiman:/root(42)# eselect opencl list Available OpenCL implementations: [1] mesa * root@caiman:/root(43)# USE=opencl emerge -v1 hwloc These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild UD ] x11-base/xorg-server-1.17.4:0/1.17.4::gentoo [1.18.0:0/1.18.0::gentoo] USE="doc glamor ipv6 kdrive nptl%* suid systemd udev wayland xorg xvfb -dmx -libressl -minimal (-selinux) -static-libs -tslib -unwind -xephyr -xnest" 0 KiB [ebuild N ] x11-drivers/ati-drivers-15.12-r1:1::gentoo USE="modules qt4 -debug -gdm-hack -pax_kernel -static-libs" ABI_X86="32 (64)" 181,617 KiB [ebuild R ] sys-apps/hwloc-1.10.1-r1:0/5::gentoo USE="X cairo numa opencl* pci plugins svg xml -cuda -debug -gl -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB Total: 3 packages (1 downgrade, 1 new, 1 reinstall), Size of downloads: 181,617 KiB !!! Multiple package instances within a single package slot have been pulled !!! into the dependency graph, resulting in a slot conflict: x11-base/xorg-server:0 (x11-base/xorg-server-1.17.4:0/1.17.4::gentoo, ebuild scheduled for merge) pulled in by <=x11-base/xorg-server-1.17.49[-minimal] required by (x11-drivers/ati-drivers-15.12-r1:1/1::gentoo, ebuild scheduled for merge) ^^ ^^^^^^^ (x11-base/xorg-server-1.18.0:0/1.18.0::gentoo, installed) pulled in by x11-base/xorg-server:0/1.18.0= required by (x11-drivers/xf86-video-ati-7.6.1:0/0::gentoo, installed) ^^^^^^^^^^ >=x11-base/xorg-server-1.18[udev] required by (x11-drivers/xf86-input-evdev-2.10.1:0/0::gentoo, installed) ^^ ^^^^ (and 4 more with the same problems) I would like to avoid the installation of ati-drivers. Is it possible to have a working gentoo installation with opencl and without ati-drivers? Even 'USE=-opencl MAKEOPTS=-j1 emerge -v1 opencv' fails with the same error. Should there not be any reference to a mesa library in the failing linker call: /usr/bin/x86_64-pc-linux-gnu-g++ -march=amdfam10 -O2 -pipe -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -Wl,-O1 -Wl,--as-needed CMakeFiles/example_text_cropped_word_recognition.dir/samples/cropped_word_recognition.cpp.o -o ../../bin/example_text_cropped_word_recognition -rdynamic ../../lib/libopencv_text.so.3.1.0 ../../lib/libopencv_features2d.so.3.1.0 ../../lib/libopencv_highgui.so.3.1.0 ../../lib/libopencv_flann.so.3.1.0 ../../lib/libopencv_ml.so.3.1.0 ../../lib/libopencv_videoio.so.3.1.0 ../../lib/libopencv_imgcodecs.so.3.1.0 ../../lib/libopencv_imgproc.so.3.1.0 ../../lib/libopencv_core.so.3.1.0 ? After emerging tesseract with -opencl I was able to emerge opencv-3.1.0 with -opencl, too. The same happens with the new tesseract-3.04.00-r4 and opencv-3.1.0-r1. If tesseract is compiled with the opencl USE flag, 'emerge -v1 opencv' fails with: /usr/lib64/libtesseract.so.3: undefined reference to `clBuildProgram'. This happens if the opencl USE flag is set for opencv and if the opencl USE flag is not set for opencv. If tesseract is compiled without the opencl USE flag, 'emerge -v1 opencv' works independent of the state of opencl USE flag for opencv. (In reply to Juergen Rose from comment #6) > The same happens with the new tesseract-3.04.00-r4 and opencv-3.1.0-r1. If > tesseract is compiled with the opencl USE flag, 'emerge -v1 opencv' fails > with: > /usr/lib64/libtesseract.so.3: undefined reference to `clBuildProgram'. > This happens if the opencl USE flag is set for opencv and if the opencl USE > flag is not set for opencv. > > If tesseract is compiled without the opencl USE flag, 'emerge -v1 opencv' > works independent of the state of opencl USE flag for opencv. I am trying to reproduce it. Trying to find out whats happening. I am able to reproduce this on my system with 1) eselect opencl mesa 2) emerge tesseract with opencl 3) emerge opencv without opencl or cuda It only occurs with opencv >= 3.0.0 It does not occur with when opencv has either cuda or opencl enabled I think the issue may be resolved by preventing autodetection of tesseract at compile time. I plan to add a tesseract use flag which will allow the opencv to explicitly depend on opencl or cuda if tesseract is compiled with opencl. It is also necessary to build opencv with the contrib use flag in order for it to fail. (In reply to Adrian from comment #9) > It is also necessary to build opencv with the contrib use flag in order for > it to fail. Yes as I told you all of those bugs are contrib bugs meaning they are in opencv_contrib. Created attachment 438450 [details, diff]
opencv-tesseract.patch
Here is a first attempt at a patch to resolve this bug.
It adds a tesseract USE flag to enable tesseract-ocr support. If tesseract is disabled then the contrib/modules/text will be compiled without tesseract. If tesseract is enabled, app-text/tesseract becomes a dependency. If tesseract was compiled with opencl support, then at least one of cuda or opencl must be enabled for opencv (I test for the converse). This provides /usr/lib/libOpenCL via eselect which has the clBuildProgram... functions to prevent this bug from occurring.
It was necessary to prevent the ebuild from disabling cuda and then continuing to build if gcc>4.8 were used. If I build tesseract with opencl and opencv built with cuda but not opencl, the previous code lead to a disconnect between the cuda USE flag (enabled) and the WITH_CUDA parameter (turned off).
The ebuild test for cuda/opencl support passes when it should fail, as it finds the cuda USE flag set for opencv even though it will soon be disabled. When cuda is disabled the WITH_CUDA parameter is turned off and the patch for FindTesseract.cmake does not link with the required libOpenCL. To fix this I call die if opencv is called with cuda enabled and gcc>4.8.
Thoughts:
The root cause of this bug is that libtesseract.so.3 has undefined symbols for the dynamic links to functions provided by libOpenCL. So any package in the tree which links to tesseract may suffer from this bug. Rather than making the changes to each package individually should a change be made the way app-text/tesseract links to libOpenCL instead to ensure the symbols are defined? Or does this defeat the purpose of dynamic linking and prevent eselect opencl from swapping out the opencl implementations without recompiling everything?
(In reply to Adrian from comment #11) > Created attachment 438450 [details, diff] [details, diff] > opencv-tesseract.patch > > Here is a first attempt at a patch to resolve this bug. > > It adds a tesseract USE flag to enable tesseract-ocr support. If tesseract > is disabled then the contrib/modules/text will be compiled without > tesseract. If tesseract is enabled, app-text/tesseract becomes a dependency. > If tesseract was compiled with opencl support, then at least one of cuda or > opencl must be enabled for opencv (I test for the converse). This provides > /usr/lib/libOpenCL via eselect which has the clBuildProgram... functions to > prevent this bug from occurring. > > It was necessary to prevent the ebuild from disabling cuda and then > continuing to build if gcc>4.8 were used. If I build tesseract with opencl > and opencv built with cuda but not opencl, the previous code lead to a > disconnect between the cuda USE flag (enabled) and the WITH_CUDA parameter > (turned off). > > The ebuild test for cuda/opencl support passes when it should fail, as it > finds the cuda USE flag set for opencv even though it will soon be disabled. > When cuda is disabled the WITH_CUDA parameter is turned off and the patch > for FindTesseract.cmake does not link with the required libOpenCL. To fix > this I call die if opencv is called with cuda enabled and gcc>4.8. > > Thoughts: > The root cause of this bug is that libtesseract.so.3 has undefined symbols > for the dynamic links to functions provided by libOpenCL. So any package in > the tree which links to tesseract may suffer from this bug. Rather than > making the changes to each package individually should a change be made the > way app-text/tesseract links to libOpenCL instead to ensure the symbols are > defined? Or does this defeat the purpose of dynamic linking and prevent > eselect opencl from swapping out the opencl implementations without > recompiling everything? I will look at it but from first view I am not very fond of this line: !opencl? ( !cuda? ( app-text/tesseract[-opencl] ) ) Created attachment 438512 [details, diff]
tesseract-3.04.00-fix-link-with-opencl.patch
Regarding my thought above I have tried patching tesseract to encourage it to link directly to /usr/lib/libOpenCL.
Unfortunately this has the side effect that using eselect opencl to set a different opencl implementation causes build failures. The linker looks for the clBuildProgram_OPENCL_1_0 functions from the implementation in use when tesseract was compiled.
Otherwise this would have greatly simplified the ebuild logic:
- The RDEPEND simplifies to tesseract? ( app-text/tesseract )
- The patch to the CMakeLists.txt just handles the use flag, the code to find and link libOpenCL is not required.
- The gcc-4.9+ logic from the previous ebuild can still be used.
Created attachment 438514 [details, diff]
opencv-tesseract-test.patch
Unfortunately from my testing above this patch does not work if eselect opencv is used to change the opencl implementation (eg nvidia to mesa) without recompiling tesseract.
It is much simpler than my previous patch, however.
Created attachment 438516 [details, diff]
opencv_contrib-3.1.0-tesseract-opencl-test.patch
This is the simplified version of the patch to the CMakeLists.txt for my test above. As noted, it does not work after when opencv implementation is changed without recompiling tesseract.
I have been trying to find another way to get rid of the !opencl? ( !cuda? ( app-text/tesseract[-opencl] ) ) Patches to tesseract itself do not work after eselect is used to change the opencl implementation. This means that tesseract will have undefined dynamically linked functions and that linking to tesseract will fail unless /usr/lib64/libOpenCL.so is linked in as well. If tesseract is built with opencl, linking with libOpenCL is required when we build opencv with tesseract and either cuda or opencl set. So I still can't find another way to get rid of that line. Perhaps it looks clearer to write: tesseract? ( opencl? ( app-text/tesseract[opencl] ) cuda? ( app-text/tesseract[opencl] ) !opencl? ( !cuda? ( app-text/tesseract[-opencl] ) ) ) or tesseract? ( opencl? ( app-text/tesseract[opencl] ) !opencl? ( cuda? ( app-text/tesseract[opencl] ) !cuda? ( app-text/tesseract[-opencl] ) ) ) The code patch to the contrib directory fails if the use flag contrib is not enabled. It needs to be enclosed in an if clause. Hey all. I'm hoping I have this fixed in the newest revision. If someone could test this before committing it to portage, that'd be great. You'll need to grab it from here: https://github.com/dracwyrm/gentoo-ebuilds/tree/master/media-libs/opencv Thanks. Is this fixed with OpenCV 3.1.0-r6? I can't test the CUDA aspect of it, but I was able to test the OpenCL part. Please report back here whether or not this is working. Thanks. No response, so closing this as resolved. If not, please ask for the bug to be reopened. |