Ask Your Question

Can not link c++ app with opencv 3.1.1 only in Ubuntu

asked 2018-09-11 02:43:46 -0500

okieiam gravatar image

System information (version) Opencv install from source follow this instruction https://opencv-java-tutorials.readthe...

$ pkg-config --modversion opencv 3.3.1 $ uname -r 4.15.13-041513-generic Ubuntu 16.04 $ g++ --version g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Detailed description Opencv build ok Java application can load opencv library and work ok. But c++ app link error $g++ -std=c++11 -ggdb pkg-config --cflags opencv decode.cpp -o decode -ldl pkg-config --libs opencv /usr/bin/x86_64-linux-gnu-ld: /usr/local/lib/libopencv_core.a(opencl_core.cpp.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/ error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

Steps to reproduce Compile demo code. Code compile and work well on os x, but error linking in Ubuntu

edit retag flag offensive close merge delete


are you using static libs ?

try putting -ldl to the END of the cmdline

berak gravatar imageberak ( 2018-09-11 04:27:17 -0500 )edit

Got this if I put -ldl to the END. All bunch of un resolve of opencv /usr/local/lib/libopencv_core.a(arithm.cpp.o): In function cv::hal::xor8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*)': arithm.cpp:(.text._ZN2cv3hal5xor8uEPKhmS2_mPhmiiPv+0x66): undefined reference toippicviXor_8u_C1R'......... .........

okieiam gravatar imageokieiam ( 2018-09-11 04:41:08 -0500 )edit

yea, and this "whack a mole" game will go on & on, since it only resolves 1 lib at a time. (now it's about ipp)

IF you want to use it from c++, maybe it's easier, to rebuild the opencv libs with BUILD_SHARED_LIBS=ON (and no java or python bindings)

berak gravatar imageberak ( 2018-09-11 05:17:39 -0500 )edit

Very sad to hear about that. So I can not co exist Java and SHARED-LIBS. Any how to install another instance of Opencv to other --prefix? Thank you for your help any way I wonder why it work on os x with opencv-java enable?

okieiam gravatar imageokieiam ( 2018-09-11 05:52:23 -0500 )edit

you CAN use java or python with BUILD_SHARED_LIBS=ON !

it's just, that the will depend on the other opencv libs (so you can't simply move it to another box)

berak gravatar imageberak ( 2018-09-11 06:31:23 -0500 )edit

Got it. Thanks.

okieiam gravatar imageokieiam ( 2018-09-11 07:26:21 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-09-11 09:37:15 -0500

okieiam gravatar image

Rebuild opencv with SHARE_LIBRARY_ON and JAVA_ON both work like a charm. Thank you.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-09-11 02:43:46 -0500

Seen: 231 times

Last updated: Sep 11 '18