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. Cross compile linker issues

Cross compile linker issues

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 3 Posters 1.2k 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.
  • L Offline
    L Offline
    Lashc
    wrote on last edited by
    #1

    I'm trying to cross compile my Qt application that uses OpenCV to a Raspberry Pi, but I keep getting linker errors, such as the following: undefined reference to `cv::putText(cv::Mat&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'

    I'm using these options in my .pro file:

    INCLUDEPATH += ~/raspi/sysroot/usr/include/opencv2/
    INCLUDEPATH += ~/raspi/sysroot/usr/include/
    LIBS += -L~/raspi/sysroot/usr/lib/
    LIBS += -lopencv_core
    LIBS += -lopencv_imgproc
    LIBS += -lopencv_highgui
    LIBS += -lopencv_ml
    LIBS += -lopencv_video
    LIBS += -lopencv_features2d
    LIBS += -lopencv_calib3d
    LIBS += -lopencv_objdetect
    LIBS += -lopencv_contrib
    LIBS += -lopencv_legacy
    LIBS += -lopencv_flann
    

    I installed OpenCV on the Raspberry Pi via the package "libopencv-dev". I've updated my sysroot and everything, but I don't know what to do from here. I've also tried using pkg-config in my .pro file, but that also left me with errors.

    aha_1980A Pablo J. RoginaP 2 Replies Last reply
    0
    • L Lashc

      I'm trying to cross compile my Qt application that uses OpenCV to a Raspberry Pi, but I keep getting linker errors, such as the following: undefined reference to `cv::putText(cv::Mat&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'

      I'm using these options in my .pro file:

      INCLUDEPATH += ~/raspi/sysroot/usr/include/opencv2/
      INCLUDEPATH += ~/raspi/sysroot/usr/include/
      LIBS += -L~/raspi/sysroot/usr/lib/
      LIBS += -lopencv_core
      LIBS += -lopencv_imgproc
      LIBS += -lopencv_highgui
      LIBS += -lopencv_ml
      LIBS += -lopencv_video
      LIBS += -lopencv_features2d
      LIBS += -lopencv_calib3d
      LIBS += -lopencv_objdetect
      LIBS += -lopencv_contrib
      LIBS += -lopencv_legacy
      LIBS += -lopencv_flann
      

      I installed OpenCV on the Raspberry Pi via the package "libopencv-dev". I've updated my sysroot and everything, but I don't know what to do from here. I've also tried using pkg-config in my .pro file, but that also left me with errors.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Lashc you should check the actual linker command line if the directories and files are correctly given.

      Qt has to stay free or it will die.

      L 1 Reply Last reply
      0
      • aha_1980A aha_1980

        @Lashc you should check the actual linker command line if the directories and files are correctly given.

        L Offline
        L Offline
        Lashc
        wrote on last edited by
        #3

        @aha_1980 Here's the appropriate portion of the make command generated by Qt Creator:
        -L/home/username/raspi/sysroot/usr/lib/arm-linux-gnueabihf -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann (where "username" is replaced by my actual username). The folder in this command is the one where the libraries are.

        aha_1980A 1 Reply Last reply
        0
        • L Lashc

          @aha_1980 Here's the appropriate portion of the make command generated by Qt Creator:
          -L/home/username/raspi/sysroot/usr/lib/arm-linux-gnueabihf -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann (where "username" is replaced by my actual username). The folder in this command is the one where the libraries are.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Lashc then you should check if these librsry files have the correct format (with file command) and if they contain the symbol you are missing. Maybe you have to add another library?

          Qt has to stay free or it will die.

          L 1 Reply Last reply
          0
          • aha_1980A aha_1980

            @Lashc then you should check if these librsry files have the correct format (with file command) and if they contain the symbol you are missing. Maybe you have to add another library?

            L Offline
            L Offline
            Lashc
            wrote on last edited by
            #5

            @aha_1980 This is the result I got from looking at one of the library files, libopencv_core.so.2.4.9, using the "file command":
            libopencv_core.so.2.4.9: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=2b27e4b60b293641d3c5a1afefa5cc5a87b30521, stripped.

            This looks fine to me for a Raspberry Pi. However, when using the "nm" command to look for symbols, I get this:
            nm: libopencv_core.so.2.4.9: no symbols. I then looked in the static library version and found a bunch of symbols. So do I need to compile with the static libraries? And if so, how?

            aha_1980A 1 Reply Last reply
            0
            • L Lashc

              @aha_1980 This is the result I got from looking at one of the library files, libopencv_core.so.2.4.9, using the "file command":
              libopencv_core.so.2.4.9: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=2b27e4b60b293641d3c5a1afefa5cc5a87b30521, stripped.

              This looks fine to me for a Raspberry Pi. However, when using the "nm" command to look for symbols, I get this:
              nm: libopencv_core.so.2.4.9: no symbols. I then looked in the static library version and found a bunch of symbols. So do I need to compile with the static libraries? And if so, how?

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Lashc I think you need to use the arm-linux-...-nm command, because the lib is cross-compiled.

              Qt has to stay free or it will die.

              L 1 Reply Last reply
              0
              • aha_1980A aha_1980

                @Lashc I think you need to use the arm-linux-...-nm command, because the lib is cross-compiled.

                L Offline
                L Offline
                Lashc
                wrote on last edited by Lashc
                #7

                @aha_1980 The OpenCV libraries were not cross compiled. They were installed natively on the Raspberry Pi through apt. If I use the "nm" command on the Raspberry Pi, I still get no symbols in the .so file but plenty in the .a file. I can natively compile C++ programs that use OpenCV on the Raspberry Pi.

                1 Reply Last reply
                0
                • L Lashc

                  I'm trying to cross compile my Qt application that uses OpenCV to a Raspberry Pi, but I keep getting linker errors, such as the following: undefined reference to `cv::putText(cv::Mat&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'

                  I'm using these options in my .pro file:

                  INCLUDEPATH += ~/raspi/sysroot/usr/include/opencv2/
                  INCLUDEPATH += ~/raspi/sysroot/usr/include/
                  LIBS += -L~/raspi/sysroot/usr/lib/
                  LIBS += -lopencv_core
                  LIBS += -lopencv_imgproc
                  LIBS += -lopencv_highgui
                  LIBS += -lopencv_ml
                  LIBS += -lopencv_video
                  LIBS += -lopencv_features2d
                  LIBS += -lopencv_calib3d
                  LIBS += -lopencv_objdetect
                  LIBS += -lopencv_contrib
                  LIBS += -lopencv_legacy
                  LIBS += -lopencv_flann
                  

                  I installed OpenCV on the Raspberry Pi via the package "libopencv-dev". I've updated my sysroot and everything, but I don't know what to do from here. I've also tried using pkg-config in my .pro file, but that also left me with errors.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #8

                  @Lashc said in Cross compile linker issues:

                  I'm using these options in my .pro file:
                  INCLUDEPATH += ~/raspi/sysroot/usr/include/opencv2/
                  INCLUDEPATH += ~/raspi/sysroot/usr/include/
                  LIBS += -L~/raspi/sysroot/usr/lib/
                  LIBS += -lopencv_core
                  LIBS += -lopencv_imgproc
                  LIBS += -lopencv_highgui
                  LIBS += -lopencv_ml
                  LIBS += -lopencv_video
                  LIBS += -lopencv_features2d
                  LIBS += -lopencv_calib3d
                  LIBS += -lopencv_objdetect
                  LIBS += -lopencv_contrib
                  LIBS += -lopencv_legacy
                  LIBS += -lopencv_flann

                  Just in case, when I was working to use Qt + OpenCV on Android, it turned out that the order of the OpenCV libraries was important. See this post as a guideline as it may also apply to you.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1

                  • Login

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