Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
Forum Update on Monday, May 27th 2025

error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
14 Posts 2 Posters 4.7k 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.
  • S swansorter

    sir,
    i cross compiled opencv 4.1.2 in my ubuntu pc (16.04) using cmake gui
    in my cmake set windowi given
    operating system arm-linux
    processor arm
    compilers:
    c: /opt/FriendlyARM/toolchain/4.9.3/bin/arm-cortexa9-linux-gnueabihf-cc
    c++: /opt/FriendlyARM/toolchain/4.9.3/bin/arm-cortexa9-linux-gnueabihf-c++
    target /opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root
    CMAKE _INSTALL_PRIFIX=usr/local/arm/openc-arm
    after cross compilation

    #-------------------------------------------------
    #
    # Project created by QtCreator 2021-03-09T14:11:00
    #
    #-------------------------------------------------
    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = opencv3
    TEMPLATE = app
    CONFIG += c++11
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    INCLUDEPATH += /usr/local/arm/opencv-arm/include/opencv4 \
        ./resources
    
    LIBS += -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect
    SOURCES += \
            main.cpp \
            mainwindow.cpp
    
    HEADERS += \
            mainwindow.h
    
    FORMS += \
            mainwindow.ui
    INSTALLS = target
    target.files = opencv3
    target.path = /home/pi
    
    

    compilation output:-

    16:50:30: Running steps for project opencv...
    16:50:30: Configuration unchanged, skipping qmake step.
    16:50:30: Starting: "/usr/bin/make"
    arm-linux-gnueabihf-g++ -fuse-ld=gold -mfloat-abi=hard --sysroot=/opt/rootfs-s5p4418 -Wl,-rpath,/usr/local/Trolltech/Qt-5.10.0-nexell32/lib -o opencv3 main.o mainwindow.o moc_mainwindow.o -L/usr/nexell-libs/lib32 -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect -L/opt/rootfs-s5p4418/usr/local/Trolltech/Qt-5.10.0-nexell32/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread
    ../opencv/mainwindow.cpp:22: error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
    collect2: error: ld returned 1 exit status
    Makefile:251: recipe for target 'opencv3' failed
    make: *** [opencv3] Error 1

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

    @swansorter said in error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':

    LIBS += -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect

    What is this?! Why do you add include folder to the libs search paths?
    What are the names of the libs inside /usr/local/arm/opencv-arm/lib?

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

    S 1 Reply Last reply
    0
    • jsulmJ jsulm

      @swansorter said in error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':

      LIBS += -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect

      What is this?! Why do you add include folder to the libs search paths?
      What are the names of the libs inside /usr/local/arm/opencv-arm/lib?

      S Offline
      S Offline
      swansorter
      wrote on last edited by
      #3

      @jsulm
      sorry it is
      LIBS += -L/usr/local/arm/opencv-arm/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect

      Screenshot from 2021-03-11 17-21-01.png

      jsulmJ 1 Reply Last reply
      0
      • S swansorter

        @jsulm
        sorry it is
        LIBS += -L/usr/local/arm/opencv-arm/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect

        Screenshot from 2021-03-11 17-21-01.png

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

        @swansorter Did you try full rebuild after fixing pro file?

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

        S 1 Reply Last reply
        0
        • jsulmJ jsulm

          @swansorter Did you try full rebuild after fixing pro file?

          S Offline
          S Offline
          swansorter
          wrote on last edited by
          #5

          @jsulm yess sir same error

          S 1 Reply Last reply
          0
          • S swansorter

            @jsulm yess sir same error

            S Offline
            S Offline
            swansorter
            wrote on last edited by
            #6

            @swansorter The m

            jsulmJ 1 Reply Last reply
            0
            • S swansorter

              @swansorter The m

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

              @swansorter Actually you should install the libs/headers in your sysroot

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

              S 1 Reply Last reply
              0
              • jsulmJ jsulm

                @swansorter Actually you should install the libs/headers in your sysroot

                S Offline
                S Offline
                swansorter
                wrote on last edited by
                #8

                @jsulm how to install the libs/headers in my sysroot

                jsulmJ 1 Reply Last reply
                0
                • S swansorter

                  @jsulm how to install the libs/headers in my sysroot

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

                  @swansorter Simply copy them to your sysroot...

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

                  S 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @swansorter Simply copy them to your sysroot...

                    S Offline
                    S Offline
                    swansorter
                    wrote on last edited by swansorter
                    #10

                    @jsulm what i need to copy and in sysroot where i need to paste?

                    jsulmJ 1 Reply Last reply
                    0
                    • S swansorter

                      @jsulm what i need to copy and in sysroot where i need to paste?

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

                      @swansorter Libs to: /opt/rootfs-s5p4418/usr/lib
                      Include files to: /opt/rootfs-s5p4418/usr/include

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

                      S 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @swansorter Libs to: /opt/rootfs-s5p4418/usr/lib
                        Include files to: /opt/rootfs-s5p4418/usr/include

                        S Offline
                        S Offline
                        swansorter
                        wrote on last edited by
                        #12

                        @jsulm
                        from : usr/local/arm/opencv-arm/libs To: /opt/rootfs-s5p4418/usr/lib
                        from : usr/local/arm/opencv-arm/include To: /opt/rootfs-s5p4418/usr/include
                        ist this write?

                        jsulmJ 1 Reply Last reply
                        0
                        • S swansorter

                          @jsulm
                          from : usr/local/arm/opencv-arm/libs To: /opt/rootfs-s5p4418/usr/lib
                          from : usr/local/arm/opencv-arm/include To: /opt/rootfs-s5p4418/usr/include
                          ist this write?

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

                          @swansorter yes

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

                          S 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @swansorter yes

                            S Offline
                            S Offline
                            swansorter
                            wrote on last edited by
                            #14

                            @jsulm i followed above steps still same error

                            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