Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build opencv with cuda error : /usr/bin/ld: cannot find -ltrue #19794

Closed
lingcong-k opened this issue Mar 26, 2021 · 9 comments
Closed

Build opencv with cuda error : /usr/bin/ld: cannot find -ltrue #19794

lingcong-k opened this issue Mar 26, 2021 · 9 comments
Labels
invalid question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org

Comments

@lingcong-k
Copy link

lingcong-k commented Mar 26, 2021

Hi, I am trying to build opencv with cuda support in dockerfile together with other stuff.
But no matter what version of opencv, I always have the following error:

Scanning dependencies of target ade
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/alloc.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/assert.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/check_cycles.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/edge.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/execution_engine.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/graph.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/memory_accessor.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/memory_descriptor.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/memory_descriptor_ref.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/memory_descriptor_view.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/metadata.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/metatypes.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/node.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/passes/communications.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/search.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/subgraphs.cpp.o
[ 22%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp.o
[ 23%] Linking CXX static library ../lib/libade.a
[ 23%] Built target ade
Scanning dependencies of target opencv_videoio_plugins
[ 23%] Built target opencv_videoio_plugins
Scanning dependencies of target opencv_cudev
[ 24%] Building CXX object modules/cudev/CMakeFiles/opencv_cudev.dir/src/stub.cpp.o
[ 24%] Linking CXX shared library ../../lib/libopencv_cudev.so
/usr/bin/ld: cannot find -ltrue
/usr/bin/ld: cannot find -ltrue
collect2: error: ld returned 1 exit status
make[2]: *** [modules/cudev/CMakeFiles/opencv_cudev.dir/build.make:105: lib/libopencv_cudev.so.4.5.0] Error 1
make[1]: *** [CMakeFiles/Makefile2:4208: modules/cudev/CMakeFiles/opencv_cudev.dir/all] Error 2
make: *** [Makefile:182: all] Error 2

**My environment is:

am using this pytorch container image nvcr.io/nvidia/pytorch:20.12-py3
(I have to use an pytorch container image in order to comply with other stuff)

cuda 11.1.1
python 3.8
ubuntu 20.04
Conda

more detailed info here: https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel_20-12.html#rel_20-12

The cmake outputs looks pretty fine for me (except for one warning):

-- 
-- General configuration for OpenCV 4.5.0 =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /opt/opencv_contrib-4.5.0/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2021-03-26T21:47:27Z
--     Host:                        Linux 5.8.0-45-generic x86_64
--     CMake:                       3.18.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (15 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (4 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 9.3.0)
--     C++ flags (Release):         -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 -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -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 -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
--     Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          m pthread cudart_static dl rt nppc nppial nppicc true nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/x86_64-linux-gnu
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab ximgproc xobjdetect xphoto
--     Disabled:                    cudacodec world xfeatures2d
--     Disabled by dependency:      sfm
--     Unavailable:                 cnn_3dobj cvv hdf java js julia matlab ovis viz
--     Applications:                perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        YES (ver 2.24.32)
--       GThread :                  YES (ver 2.64.6)
--       GtkGlExt:                  NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.0.10)
--     JPEG 2000:                   build (ver 2.3.1)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (58.54.100)
--       avformat:                  YES (58.29.100)
--       avutil:                    YES (56.31.100)
--       swscale:                   YES (5.5.100)
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   /opt/opencv-4.5.0/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                /opt/opencv-4.5.0/build/3rdparty/ippicv/ippicv_lnx/iw
--     Lapack:                      YES (/opt/conda/lib/libmkl_intel_lp64.so /opt/conda/lib/libmkl_sequential.so /opt/conda/lib/libmkl_core.so /opt/conda/lib/libmkl_intel_lp64.so /opt/conda/lib/libmkl_sequential.so /opt/conda/lib/libmkl_core.so /opt/conda/lib/libmkl_intel_lp64.so /opt/conda/lib/libmkl_sequential.so /opt/conda/lib/libmkl_core.so -lpthread -lm -ldl)
--     Eigen:                       YES (ver 3.3.7)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 11.1, CUFFT CUBLAS)
--     NVIDIA GPU arch:             35 37 50 52 60 61 70 75 80 86
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 8.0.5)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /opt/opencv-4.5.0/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.18)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.18)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)
--     install path:                lib/python2.7/dist-packages/cv2/python-2.7
-- 
--   Python 3:
--     Interpreter:                 /opt/conda/bin/python3.8 (ver 3.8.5)
--     Libraries:                   /opt/conda/lib/libpython3.8m.so
--     numpy:                       /opt/conda/lib/python3.8/site-packages/numpy/core/include (ver 1.19.2)
--     install path:                /opt/conda/lib/python3.8/site-packages/cv2/python-3.8
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
CMake Warning at cmake/OpenCVUtils.cmake:1508 (add_library):
  Cannot generate a safe runtime search path for target opencv_core because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /opt/conda/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  cmake/OpenCVModule.cmake:930 (ocv_add_library)
  cmake/OpenCVModule.cmake:851 (_ocv_create_module)
  modules/core/CMakeLists.txt:104 (ocv_create_module)

the command am using is:

RUN apt-get update && apt-get upgrade -y &&\
    # Install build tools, build dependencies and python
    apt-get install -y \
	    python3-pip \
        build-essential \
        cmake \
        git \
        wget \
        unzip \
        yasm \
        pkg-config \
        libswscale-dev \
        libtbb2 \
        libtbb-dev \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        libavformat-dev \
        libpq-dev \
        libxine2-dev \
        libglew-dev \
        libtiff5-dev \
        zlib1g-dev \
        libjpeg-dev \
        libavcodec-dev \
        libavformat-dev \
        libavutil-dev \
        libpostproc-dev \
        libswscale-dev \
        libeigen3-dev \
        libtbb-dev \
        libgtk2.0-dev \
        pkg-config \
        libopenblas-dev \
        liblapack-dev \
        libatlas-base-dev \
        ## Python
        python-dev \
        python-numpy \
        python3-dev \
        python3-numpy \
        python3.8-dev \
        libpython3-dev \
        libpython3.8-dev \
        libpython2.7-dev \
    && rm -rf /var/lib/apt/lists/*

ARG OPENCV_VERSION=4.5.0

# RUN cd /usr/include &&\
# ln -s python3.6m python3.6

RUN cd /opt/ &&\
    # Download and unzip OpenCV and opencv_contrib and delte zip files
    wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip &&\
    unzip $OPENCV_VERSION.zip &&\
    rm $OPENCV_VERSION.zip &&\
    wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip &&\
    unzip ${OPENCV_VERSION}.zip &&\
    rm ${OPENCV_VERSION}.zip &&\
    # Create build folder and switch to it
    mkdir /opt/opencv-${OPENCV_VERSION}/build && cd /opt/opencv-${OPENCV_VERSION}/build &&\
    # Cmake configure
    cmake \
        -DBUILD_opencv_python3=yes \
        -DHAVE_opencv_python3=ON \
        -DPYTHON3_EXECUTABLE=/opt/conda/bin/python3.8 \
        -DPYTHON3_LIBRARY=/opt/conda/lib/libpython3.8m.so \
        -DOPENCV_PYTHON3_INSTALL_PATH=/opt/conda/lib/python3.8/site-packages \
        -DPYTHON3_INCLUDE_DIR=/opt/conda/include \
        -DPYTHON3_PACKAGES_PATH= /opt/conda/lib/site-packages \
        -DPYTHON3_NUMPY_INCLUDE_DIR= /opt/conda/lib/python3.8/site-packages/numpy/core/include \
        -DOPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
        -DWITH_CUDA=ON \
        -DCMAKE_BUILD_TYPE=RELEASE \
        -DWITH_CUDNN=ON \
        -DOPENCV_DNN_CUDA=ON \
        -DWITH_OPENGL=ON \
        -DCUDA_nppicom_LIBRARY=true\
        -DCUDA_nppicom_LIBRARY=true\
        -DENABLE_PRECOMPILED_HEADERS=OFF \
        -DBUILD_TIFF=ON \
        -DBUILD_TESTS=OFF \
#         -DCUDA_ARCH_BIN=7.5 \
        # Install path will be /usr/local/lib (lib is implicit)
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
        -DBUILD_opencv_cudacodec=OFF \
        -DBUILD_opencv_xfeatures2d=OFF \
#         -DCMAKE_INSTALL_PREFIX=$(python3.6 -c "import sys; print(sys.prefix)") \
#         -DPYTHON_EXECUTABLE=$(which python3.6) \
#         -DPYTHON_INCLUDE_DIR=$(python3.6 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
#         -DPYTHON_PACKAGES_PATH=$(python3.6 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
        .. &&\
    # Make
    make && \
    # Install to /usr/local/lib
    make install && \
    ldconfig &&\
    # Remove OpenCV sources and build folder
    rm -rf /opt/opencv-${OPENCV_VERSION} && rm -rf /opt/opencv_contrib-${OPENCV_VERSION}

Can someone please help, being stuck for 2 days ;( Thanks

@lingcong-k lingcong-k changed the title can't find Linking CXX shared library ../../lib/libopencv_cudev.so Build opencv with cuda error : can't find Linking CXX shared library ../../lib/libopencv_cudev.so Mar 26, 2021
@lingcong-k lingcong-k changed the title Build opencv with cuda error : can't find Linking CXX shared library ../../lib/libopencv_cudev.so Build opencv with cuda error : /usr/bin/ld: cannot find -ltrue Mar 28, 2021
@windson87
Copy link

it seems can not find libtrue.so file... but i googled so long, didnt find any lib have sth to do with that..

@alalek
Copy link
Member

alalek commented Mar 28, 2021

-DCUDA_nppicom_LIBRARY=true\
-DCUDA_nppicom_LIBRARY=true\

You have googled wrong instructions. Problem comes from here.
There is nothing to fix in OpenCV.

@windson87
Copy link

-DCUDA_nppicom_LIBRARY=true\
-DCUDA_nppicom_LIBRARY=true\

You have googled wrong instructions. Problem comes from here.
There is nothing to fix in OpenCV.
Thanks. i encountered different errors.. this flag was read somewhere. But now i can build successfully.. Thanks

@yz1756642101
Copy link

Dear lingcong-k, can you tell me how you solved this problem? I met the same error : /usr/bin/ld: cannot find -ltrue. I haven't solved it yet. This problem has bothered me for a long time. :( Thanks.

@AndrewMorgan2
Copy link

Has a solution to this been reached by anyone

@cy-2022
Copy link

cy-2022 commented Feb 22, 2023

It is indeed due to -DCUDA_nppicom_LIBRARY=true. Try -DCUDA_nppicom_LIBRARY=false, you'd get an error that goes "/usr/bin/ld: cannot find -lfalse".

In my case, as I don't have to have CUDA involved, I simply "switch it off" by adding -DWITH_CUDA:BOOL="0" to the cmake command. And it worked. Hopefully this is helpful.

@HHH006
Copy link

HHH006 commented Apr 6, 2023

Hello, I'm having the same problem as you! Have you solved it? I was really stuck for a long time

@wgsP
Copy link

wgsP commented Nov 2, 2023

-DCUDA_nppicom_LIBRARY=true\
Try changing to
-DCUDA_nppicom_LIBRARY=true \

@wgsP
Copy link

wgsP commented Nov 2, 2023

-DCUDA_nppicom_LIBRARY=true\ Try changing to -DCUDA_nppicom_LIBRARY=true \

The information filled in here may not be 'true' or 'false', but rather the path to a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org
Projects
None yet
Development

No branches or pull requests

8 participants