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. How can I create a cross-platform Qt app which uses OpenCV?
QtWS25 Last Chance

How can I create a cross-platform Qt app which uses OpenCV?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 3.9k 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.
  • P Offline
    P Offline
    prerna1
    wrote on last edited by
    #1

    I have compiled the OpenCV library & places the dylibs into a folder and included the dylibs by writing
    LIBS += /myproject/...executablepath/opencv_lib/*.dylib in my project's .pro file

    The above works if I have files in /usr/local/lib, however it does NOT work when these dylibs are not there in /usr/local/lib.

    I want to create a Qt app which "bundles" OpenCV with it, such that the user does NOT need to install OpenCV himself before running the app. Now that I have already included the dylibs in my project, why should the libraries need to be there in /usr/local/lib also?

    Please help!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Two things you should know:

      1. Your shared library should be found by linker at the build time. You have done this by passing it to the linker.

      2. You shared library should be found by your application at the run time. Seems you have forget this.


      You can use environment variable such as %PATH% under windows, $LD_LIBRARY_PATH under linux, and $DYLD_LIBRARY_PATH under macos.

      or you can use rpath or loader_path for *nix system.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        To add to what 1+1=2 said, you can also compile OpenCV statically and link to these libraries so there would be no need to install them

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          prerna1
          wrote on last edited by
          #4

          1+1=2 can you please be more specific about how to the #2 in Qt? I am still very new to Qt.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            prerna1
            wrote on last edited by
            #5

            SGaist, I compiled static libraries for OpenCV using cmake, but they just did not work! :(

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What doesn't work ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                prerna1
                wrote on last edited by
                #7

                Well, when I run cmake to compile the static libraries, it stops at 33%, so I believe I don't get all the libraries. When I include the libraries I get, it gives me some error. Can I get static libraries for OpenCV through some other way?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Indeed that's strange, you should go to the OpenCV forum to get help for building it statically.

                  In between, if you want to use the dynamic version, use 1+1=2's advice. The technique is explained there
                  [quote author="1+1=2" date="1378187807"]
                  You can use environment variable such as %PATH% under windows, $LD_LIBRARY_PATH under linux, and $DYLD_LIBRARY_PATH under macos.
                  [/quote]

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dbzhang800
                    wrote on last edited by
                    #9

                    Hi, this is not a Qt problem, this is a common system concept and it is valid for C/C++/fortran/...

                    When shared library used, you must tell your application where the library can be found if it's not located in system default path.

                    There are two ways to do so.

                    • The first one is make use of system variable
                    • Another one is embedded the library path, which is the installed path of your library when your deploy your application, to you application when you build your application.

                    [quote author="prerna" date="1378220070"]1+1=2 can you please be more specific about how to the #2 in Qt? I am still very new to Qt.[/quote]

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      prerna1
                      wrote on last edited by
                      #10

                      Hey! Well, it worked now! I understand that this is not a Qt problem. I have faced this before as well and gotten it to work. Problem was that I had tried setting DYLD_LIBRARY_PATH to /Users/..../project/deploy/lib i.e. an absolute path and it did not work!
                      My working directory and DESTDIR is /Users/..../project/deploy. So, I tried setting DYLD_LIBRARY_PATH to ./lib and it worked perfectly!

                      [quote author="1+1=2" date="1378257473"]Hi, this is not a Qt problem, this is a common system concept and it is valid for C/C++/fortran/...

                      When shared library used, you must tell your application where the library can be found if it's not located in system default path.

                      There are two ways to do so.

                      • The first one is make use of system variable
                      • Another one is embedded the library path, which is the installed path of your library when your deploy your application, to you application when you build your application.

                      [quote author="prerna" date="1378220070"]1+1=2 can you please be more specific about how to the #2 in Qt? I am still very new to Qt.[/quote]

                      [/quote]

                      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