Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++
Forum Update on Monday, May 27th 2025

OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 767 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DQUY05D Offline
    DQUY05D Offline
    DQUY05
    wrote on last edited by
    #1

    Hi everyone !

    I'm new bie, and I don't speak English well , I need use opencv lib for Qt, but have error code :

    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [libuntitled_armeabi-v7a.so] Error 1
    22:00:06: The process "C:\Qt\android-ndk-r20b\prebuilt\windows-x86_64\bin\make.exe" exited with code 2.
    Error while building/deploying project untitled (kit: Android for armeabi-v7a,arm64-v8a,x86,x86_64 (Clang Qt 5.14.2 for Android))
    When executing step "Make"
    

    With .pro file:

    OPENCVSDKNATIVE = C:/OpenCV-android-sdk/sdk/native
    INCLUDEPATH += $$OPENCVSDKNATIVE/jni/include
    
    equals(ANDROID_TARGET_ARCH, armeabi-v7a) {
        message("setting armeabi-v7a OPENCV libs")
    
        # OPENCV LIBS
    LIBS +=\
        -L"$$OPENCVSDKNATIVE/3rdparty/libs/armeabi-v7a"\
        -L"$$OPENCVSDKNATIVE/staticlibs/armeabi-v7a"\
        -llibtiff -llibpng -lIlmImf -llibprotobuf\
        -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio\
    
        ANDROID_EXTRA_LIBS += $$OPENCVSDKNATIVE/libs/armeabi-v7a/libopencv_java4.so
    }
    

    Can you help me?
    Many thanks !

    jsulmJ 1 Reply Last reply
    0
    • DQUY05D DQUY05

      Hi everyone !

      I'm new bie, and I don't speak English well , I need use opencv lib for Qt, but have error code :

      clang++: error: linker command failed with exit code 1 (use -v to see invocation)
      make: *** [libuntitled_armeabi-v7a.so] Error 1
      22:00:06: The process "C:\Qt\android-ndk-r20b\prebuilt\windows-x86_64\bin\make.exe" exited with code 2.
      Error while building/deploying project untitled (kit: Android for armeabi-v7a,arm64-v8a,x86,x86_64 (Clang Qt 5.14.2 for Android))
      When executing step "Make"
      

      With .pro file:

      OPENCVSDKNATIVE = C:/OpenCV-android-sdk/sdk/native
      INCLUDEPATH += $$OPENCVSDKNATIVE/jni/include
      
      equals(ANDROID_TARGET_ARCH, armeabi-v7a) {
          message("setting armeabi-v7a OPENCV libs")
      
          # OPENCV LIBS
      LIBS +=\
          -L"$$OPENCVSDKNATIVE/3rdparty/libs/armeabi-v7a"\
          -L"$$OPENCVSDKNATIVE/staticlibs/armeabi-v7a"\
          -llibtiff -llibpng -lIlmImf -llibprotobuf\
          -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio\
      
          ANDROID_EXTRA_LIBS += $$OPENCVSDKNATIVE/libs/armeabi-v7a/libopencv_java4.so
      }
      

      Can you help me?
      Many thanks !

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @DQUY05 said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

      clang++: error: linker command failed with exit code 1 (use -v to see invocation)

      Please post the actual linker error (should be above that line).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      DQUY05D 1 Reply Last reply
      0
      • jsulmJ jsulm

        @DQUY05 said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

        clang++: error: linker command failed with exit code 1 (use -v to see invocation)

        Please post the actual linker error (should be above that line).

        DQUY05D Offline
        DQUY05D Offline
        DQUY05
        wrote on last edited by
        #3

        @jsulm

        I fixed the error, but the function is always false , and the camera cannot be opened

            capture.open(1);
        
            if(!capture.isOpened())
            {
                ui->inform->setText("NG camera");
                qDebug() << "Could not open camera" << 1;
            }
        else
            {
                ui->inform->setText("OK camera");
                qDebug() << "Opened camera" << 1;
            }
        

        .cpp file

        #include <opencv2/core.hpp>
        #include "opencv2/opencv.hpp"
        #include <opencv2/core/mat.hpp>
        #include <opencv2/core/mat.inl.hpp>
        
        #include <opencv2/core.hpp>
        #include <opencv2/videoio.hpp>
        #include <opencv2/highgui.hpp>
        #include <opencv2/imgproc.hpp>  // cv::Canny()
        #include <iostream>
        

        .pro file

        android {
            contains(ANDROID_TARGET_ARCH,arm64-v8a) {
                isEmpty(OPENCV_ANDROID) {
                    error("Let OPENCV_ANDROID point to the opencv-android-sdk, recommended: v4.0")
                }
                INCLUDEPATH += "$$OPENCV_ANDROID/sdk/native/jni/include"
                LIBS += \
                    -L"$$OPENCV_ANDROID/sdk/native/libs/arm64-v8a" \
                    -L"$$OPENCV_ANDROID/sdk/native/3rdparty/libs/arm64-v8a" \
                    -llibtiff \
                    -llibjpeg-turbo \
                    -llibpng \
                    -lIlmImf \
                    -ltbb \
                    -ltegra_hal \
                    -lade \
                    -lcpufeatures \
                    -lopencv_java4 \
        
                ANDROID_EXTRA_LIBS = $$OPENCV_ANDROID/sdk/native/libs/arm64-v8a/libopencv_java4.so
            } else {
                error("Unsupported architecture: $$ANDROID_TARGET_ARCH")
            }
        }
        

        App output

        D libuntitled_arm64-v8a.so: Could not open camera 1
        

        I hope you will help me,
        Thanks!

        jsulmJ 1 Reply Last reply
        0
        • DQUY05D DQUY05

          @jsulm

          I fixed the error, but the function is always false , and the camera cannot be opened

              capture.open(1);
          
              if(!capture.isOpened())
              {
                  ui->inform->setText("NG camera");
                  qDebug() << "Could not open camera" << 1;
              }
          else
              {
                  ui->inform->setText("OK camera");
                  qDebug() << "Opened camera" << 1;
              }
          

          .cpp file

          #include <opencv2/core.hpp>
          #include "opencv2/opencv.hpp"
          #include <opencv2/core/mat.hpp>
          #include <opencv2/core/mat.inl.hpp>
          
          #include <opencv2/core.hpp>
          #include <opencv2/videoio.hpp>
          #include <opencv2/highgui.hpp>
          #include <opencv2/imgproc.hpp>  // cv::Canny()
          #include <iostream>
          

          .pro file

          android {
              contains(ANDROID_TARGET_ARCH,arm64-v8a) {
                  isEmpty(OPENCV_ANDROID) {
                      error("Let OPENCV_ANDROID point to the opencv-android-sdk, recommended: v4.0")
                  }
                  INCLUDEPATH += "$$OPENCV_ANDROID/sdk/native/jni/include"
                  LIBS += \
                      -L"$$OPENCV_ANDROID/sdk/native/libs/arm64-v8a" \
                      -L"$$OPENCV_ANDROID/sdk/native/3rdparty/libs/arm64-v8a" \
                      -llibtiff \
                      -llibjpeg-turbo \
                      -llibpng \
                      -lIlmImf \
                      -ltbb \
                      -ltegra_hal \
                      -lade \
                      -lcpufeatures \
                      -lopencv_java4 \
          
                  ANDROID_EXTRA_LIBS = $$OPENCV_ANDROID/sdk/native/libs/arm64-v8a/libopencv_java4.so
              } else {
                  error("Unsupported architecture: $$ANDROID_TARGET_ARCH")
              }
          }
          

          App output

          D libuntitled_arm64-v8a.so: Could not open camera 1
          

          I hope you will help me,
          Thanks!

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @DQUY05 said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

          I hope you will help me

          This is an issue with OpenCV, not Qt. You should ask in a OpenCV forum.
          One possible reason for your problem: on Android an app has to request rights to access camera.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          DQUY05D 1 Reply Last reply
          0
          • jsulmJ jsulm

            @DQUY05 said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

            I hope you will help me

            This is an issue with OpenCV, not Qt. You should ask in a OpenCV forum.
            One possible reason for your problem: on Android an app has to request rights to access camera.

            DQUY05D Offline
            DQUY05D Offline
            DQUY05
            wrote on last edited by
            #5

            @jsulm said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

            @DQUY05 said in OpenCV-4.5.2 and Android NDK20, Kit armeabi-v7a, C++:

            I hope you will help me

            This is an issue with OpenCV, not Qt. You should ask in a OpenCV forum.
            One possible reason for your problem: on Android an app has to request rights to access camera.

            I have add a function that requires to use the camera already

            #include <QtAndroidExtras/QtAndroid>
            #include <QtAndroidExtras/QtAndroid>
            #include <QtMultimedia/qmultimedia.h>
            

            and

                auto  result = QtAndroid::checkPermission(QString("android.permission.CAMERA"));
                    if(result == QtAndroid::PermissionResult::Denied){
                        QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(QStringList({"android.permission.CAMERA"}));
                        if(resultHash["android.permission.CAMERA"] == QtAndroid::PermissionResult::Denied)
                        {
            
                        }
                    }
            

            and .xml file

            <uses-permission android:name="android.permission.CAMERA"/>
            <uses-feature android:name="android.hardware.camera" android:required="true"/>
            <uses-feature android:name="android.hardware.camera.autofocus" android:required="true"/>
            <uses-feature android:name="android.hardware.camera.front" android:required="true"/>
            <uses-feature android:name="android.hardware.camera.front.autofocus" android:required="true"/>
            

            But not work!
            Many thanks!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved