Link error in core/ocl

asked 2015-03-20 13:07:00 -0600

updated 2015-03-23 06:35:39 -0600

Today I was able to run (finaly!!!) the cross compilation but I wasn't able to fix that error:

Linking CXX shared library ../../lib/libopencv_core.so
CMakeFiles/opencv_core.dir/src/ocl.cpp.o: In function `initOpenCLAndLoad':
ocl.cpp:(.text.initOpenCLAndLoad+0x40): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/hristov/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen':
(.text+0xc): undefined reference to `__dlopen'
/home/hristov/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): In function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_core.so.3.0.0] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2
hristov@hristov-OptiPlex-755:~/workspace/opencv/build$

I'm not using OpenCL (WITH_OPENCL = OFF) but I'm still getting that error ;? Any ideas ?

p.p. My toolchain file :

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(GCC_COMPILER_VERSION "4.8.3" CACHE STRING "GCC Compiler version")

set(FLOAT_ABI_SUFFIX "hf")

set(CMAKE_C_COMPILER    /home/hristov/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER  /home/hristov/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)
set(ARM_LINUX_SYSROOT   /home/hristov/workspace/rootfs)


set(CMAKE_CXX_FLAGS           ""                    CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS             ""                    CACHE STRING "c flags")
set(CMAKE_SHARED_LINKER_FLAGS ""                    CACHE STRING "shared linker flags")
set(CMAKE_MODULE_LINKER_FLAGS ""                    CACHE STRING "module linker flags")
set(CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"  CACHE STRING "executable linker flags")

set(CMAKE_CXX_FLAGS "-mcpu=armv6 -O3 -mfloat-abi=hard -ftree-vectorize -ftree-vectorizer-verbose=9" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "-mcpu=armv6 -O3 -mfloat-abi=hard -ftree-vectorize -ftree-vectorizer-verbose=9" CACHE STRING "c flags")

set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS    "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_EXE_LINKER_FLAGS}")

if(USE_NEON)
  message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." )
  set(ENABLE_NEON TRUE)
elseif(USE_VFPV3)
  message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." )
  set(ENABLE_VFPV3 TRUE)
endif()

set(CMAKE_FIND_ROOT_PATH ${ARM_LINUX_SYSROOT})

set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
edit retag flag offensive close merge delete

Comments

Could you please show the entire CMAKE statement that you used?

Potato gravatar imagePotato ( 2015-03-20 13:54:36 -0600 )edit

cmake -DCMAKE_TOOLCHAIN_FILE=../../arm-gnueabi.toolchain.cmake -D WITH_GTK=ON WITH_OPENCL=NO ../

Spas Hristov gravatar imageSpas Hristov ( 2015-03-23 06:34:08 -0600 )edit

opencv_core apparently needs `__dlopen' function to compile and is not finding it. Try adding the "dl" libary to your libs in linker list.

Pedro Batista gravatar imagePedro Batista ( 2015-03-23 06:55:38 -0600 )edit