Author Topic: opencv 4.1.0 on Jeston Nano linking with CB  (Read 4245 times)

Offline Gandalf2019

  • Single posting newcomer
  • *
  • Posts: 3
opencv 4.1.0 on Jeston Nano linking with CB
« on: September 25, 2019, 06:50:26 pm »
I installed opencv 4.1.0 using the following modified installer it worked perfect (you only need to increase memory swap - I increased it to 8GB).
install_opencv4.1.0_Nano.sh (here is the following code for your use by the end of this post - without swap modification).

I made some modification in the original file, one of them is that i skipped installing python 2 binding if someone need it change the flag -D BUILD_opencv_python2=OFF to ON).

After installation, when running opencv c++ code using cmake and CMakeLists.txt (as recommended by opencv) everything works perfectly (i tested opencv version and get 4.1.0), I've tested cuda acceleration with opencv and it works, perfectly. i tested python 3 as well and everything works good.


I downloaded and install latest code::blocks IDE, and tested the hello world with native GCC compiler (default).

when trying to link opencv and use this IDE nothing works, no auto-complete, build errors etc.
i set the following:
1. compiler search directories: /usr/local/include/opencv4/
2. linker tab - usr/local/bin/
3. tried list of libs.

I'll appreciate if someone will try the installer below, and provide instructions (for dummies), how to link latest code:blocks IDE with this opencv installation that can be build and run\debug using it, with autocomplete.

many thanks

Code
    #!/bin/bash
    #
    # Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
    #
    # NVIDIA Corporation and its licensors retain all intellectual property
    # and proprietary rights in and to this software, related documentation
    # and any modifications thereto.  Any use, reproduction, disclosure or
    # distribution of this software and related documentation without an express
    # license agreement from NVIDIA Corporation is strictly prohibited.
    #

    if [ "$#" -ne 1 ]; then
        echo "Usage: $0 <Install Folder>"
        exit
    fi
    folder="$1"
    user="nvidia"
    passwd="nvidia"

    echo "** Remove OpenCV3.3 first"
    sudo sudo apt-get purge *libopencv*

    echo "** Install requirement"
    sudo apt-get update
    sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
    sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
    sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
    sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
    sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
    sudo apt-get install -y curl
    sudo apt-get update

    echo "** Download opencv-4.1.0"
    cd $folder
    curl -L https://github.com/opencv/opencv/archive/4.1.0.zip -o opencv-4.1.0.zip
    curl -L https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -o opencv_contrib-4.1.0.zip
    unzip opencv-4.1.0.zip
    unzip opencv_contrib-4.1.0.zip
    cd opencv-4.1.0/

    echo "** Building..."
    mkdir release
    cd release/
    cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules -D OPENCV_ENABLE_NONFREE=OFF -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    make -j3
    sudo make install
    s
    echo "** Install opencv-4.1.0 successfully"
    echo "** Bye :)"

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: opencv 4.1.0 on Jeston Nano linking with CB
« Reply #1 on: September 25, 2019, 08:24:59 pm »

Offline Gandalf2019

  • Single posting newcomer
  • *
  • Posts: 3
Re: opencv 4.1.0 on Jeston Nano linking with CB
« Reply #2 on: September 26, 2019, 06:40:50 am »
Great, it is a great help  8) many thanks.

to make my question\s short, previous linking DOES NOT WORK. Hence, if any linking option that i've tried doesn't work guess what the errors are? are the same as if i linked nothing.

I truely need assistance with it.

the only thing that links and compiled is if i write the line:
#include <opencv2/opencv.hpp>

and on compiler tab (search directories) i include the following path: /usr/local/include/opencv4/

the rest linking is a puzzle

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: opencv 4.1.0 on Jeston Nano linking with CB
« Reply #3 on: September 26, 2019, 08:31:20 am »
Still we NEED the FULL REBUILD LOG to help you.... This is clearly written in the FAQ
without error log no help, not because we do not want, but because we do not can...

Offline Gandalf2019

  • Single posting newcomer
  • *
  • Posts: 3
Re: opencv 4.1.0 on Jeston Nano linking with CB
« Reply #4 on: September 28, 2019, 08:47:15 pm »
Hi,

I made some progress. and now i can share build error that may hint the nature of the linking error.

the error:
Quote
-------------- Build: Release in test1 (compiler: GNU GCC Compiler)---------------

g++ -L/usr/local/lib/ -o bin/Release/test1 obj/Release/main.o  -s -Iopencv_cudev -Iopencv_core -Iopencv_cudaarithm -Iopencv_flann -Iopencv_imgproc -Iopencv_ml -Iopencv_phase_unwrapping -Iopencv_plot -Iopencv_quality -Iopencv_reg -Iopencv_surface_matching -Iopencv_cudafilters -Iopencv_cudaimgproc -Iopencv_cudawarping -Iopencv_dnn -Iopencv_freetype -Iopencv_fuzzy -Iopencv_gapi -Iopencv_hfs -Iopencv_img_hash -Iopencv_imgcodecs -Iopencv_photo -Iopencv_videoio -Iopencv_xphoto -Iopencv_cudacodec -Iopencv_highgui -Iopencv_bioinspired -Iopencv_dnn_objdetect -Iopencv_features2d -Iopencv_line_descriptor -Iopencv_saliency -Iopencv_text -Iopencv_calib3d -Iopencv_ccalib -Iopencv_cudafeatures2d -Iopencv_cudastereo -Iopencv_datasets -Iopencv_objdetect -Iopencv_rgbd -Iopencv_shape -Iopencv_structured_light -Iopencv_video -Iopencv_xfeatures2d -Iopencv_ximgproc -Iopencv_xobjdetect -Iopencv_aruco -Iopencv_bgsegm -Iopencv_cudabgsegm -Iopencv_cudalegacy -Iopencv_cudaobjdetect -Iopencv_dpm -Iopencv_face -Iopencv_optflow -Iopencv_stitching -Iopencv_tracking -Iopencv_cudaoptflow -Iopencv_stereo -Iopencv_superres -Iopencv_videostab 
obj/Release/main.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x84): undefined reference to `cv::fastFree(void*)'
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x94): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 


the source code is in the following screenshot:
Code
#include <iostream>
#include <opencv2/opencv.hpp>
int main()
{
    cv::Mat A;
    std::cout << "Opencv linked" << std::endl;
    return 0;
}

in "Search directories" tab > Compiler i added the following link: /usr/local/include/opencv4/
in "Search directories" tab > Linker i added the following link: /usr/local/lib/
in "linker setting" tab > i added the list that appears in the error message. \

I'm sure it is linking error.

please advise

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: opencv 4.1.0 on Jeston Nano linking with CB
« Reply #5 on: September 29, 2019, 01:39:09 am »
Do you know the difference between "I" and "l"?

What you put somewhere!
Code
-Iopencv_cudev

What you likely should have used
Code
-lopencv_cudev

or just used the library name in the list of libraries.
Code
opencv_cudev

Did you do something stupid in the Advanced Compiler settings?
Edit: I believe you could break it there, also.

Tim S.

« Last Edit: September 29, 2019, 01:40:45 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org