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. Cannot find Oracle::OCI when using statically built Qt
QtWS25 Last Chance

Cannot find Oracle::OCI when using statically built Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 340 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.
  • Y Offline
    Y Offline
    Yihua Liu
    wrote on last edited by
    #1

    I built and installed a statically built Qt to /opt/qt-static, then referring to https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-oci-plugin-on-unix-and-macos I want to use QOCI Oracle SQL driver in my app. I successfully built the libqsqloci.a in build-sqldrivers/plugins/sqldrivers and installed to /opt/qt-static by

    /opt/qt-static/bin/qt-cmake -G Ninja ~/qt-everywhere-src-6.8.1/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/opt/qt-static -DOracle_ROOT=/home/yihua/app/yihua/product/21.0.0/client_1 -DQT_GENERATE_SBOM=OFF
    

    However, when I cmake configure my qt app, it shows error:

    [cmake] -- Configuring done
    [cmake] CMake Error at /opt/qt-static/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:695 (add_executable):
    [cmake] Target "MyApp" links to target "Oracle::OCI" but the target was not
    [cmake] found. Perhaps a find_package() call is missing for an IMPORTED target, or
    [cmake] an ALIAS target is missing?
    [cmake] Call Stack (most recent call first):
    [cmake] /opt/qt-static/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:646 (_qt_internal_create_executable)
    [cmake] /opt/qt-static/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:945 (qt6_add_executable)
    [cmake] CMakeLists.txt:69 (qt_add_executable)

    I checked that there is libqsqloci.a under /opt/qt-static/plugins/sqldrivers. Why MyApp still cannot find Oracle::OCI?

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

      Hi,

      How are you linking the static plugin ?

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

      Y 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How are you linking the static plugin ?

        Y Offline
        Y Offline
        Yihua Liu
        wrote on last edited by Yihua Liu
        #3

        @SGaist Hi, I'm using qt_import_plugins(MyApp INCLUDE_BY_TYPE sqldrivers) to link the static plugin; no matter I add this line or not the problem exists

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          Yihua Liu
          wrote on last edited by Yihua Liu
          #4

          Originally using qt-static the project can be successfully built, just problematic when running MyApp that shows errors "QOCI driver not available." QSqlDatabase: QOCI driver not loaded; however, after I install libqsqloci.a to qt-static, the CMake configure fails as shown above

          My CMakeLists.txt includes

          find_package(Qt6 6.8 REQUIRED COMPONENTS Charts Core Gui Qml Quick Sql)
          qt_add_executable(MyApp WIN32 MACOSX_BUNDLE)
          target_link_libraries(MyApp PRIVATE
                  Qt6::Charts
                  Qt6::Core
                  Qt6::Gui
                  Qt6::Qml
                  Qt6::Quick
                  Qt6::Sql
                  QXlsx::QXlsx
          )
          
          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            Yihua Liu
            wrote on last edited by
            #5

            Additionally, after generating done, CMake error is:

            [cmake] -- Generating done
            [cmake] CMake Error:
            [cmake]   Running
            [cmake] 
            [cmake]    '/usr/bin/ninja' '-C' '/home/yihua/MyApp/build/Desktop_Qt_6_8_1-Debug' '-t' 'recompact'
            [cmake] 
            [cmake]   failed with:
            [cmake] 
            [cmake]    ninja: error: build.ninja:35: loading 'CMakeFiles/rules.ninja': No such file or directory
            [cmake] 
            [cmake]   include CMakeFiles/rules.ninja
            [cmake] 
            [cmake]                                 ^ near here
            [cmake] 
            [cmake] 
            [cmake] 
            [cmake] CMake Generate step failed.  Build files cannot be regenerated correctly.
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Please provide minimal CMakelists.txt that shows this behaviour.

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

              Y 1 Reply Last reply
              0
              • SGaistS SGaist

                Please provide minimal CMakelists.txt that shows this behaviour.

                Y Offline
                Y Offline
                Yihua Liu
                wrote on last edited by
                #7

                @SGaist This is my minimal CMakeLists.txt:

                cmake_minimum_required(VERSION 3.22)
                
                option(LINK_INSIGHT "Link Qt Insight Tracker library" ON)
                option(BUILD_QDS_COMPONENTS "Build design studio components" ON)
                option(BUILD_TESTS "Enable building tests" OFF)
                
                project(MyApp
                        VERSION 1.0.0
                        DESCRIPTION "..."
                        HOMEPAGE_URL "..."
                        LANGUAGES CXX)
                find_package(Qt6 6.8 REQUIRED COMPONENTS Charts Core Gui Qml Quick Sql)
                set(CMAKE_AUTOMOC ON)
                set(CMAKE_AUTOUIC ON)
                set(CMAKE_AUTORCC ON)
                find_package(Boost 1.83.0 REQUIRED)
                
                include_directories(${Boost_INCLUDE_DIRS})
                include_directories(src)
                include_directories(src/material)
                include_directories(src/sql)
                
                if (Qt6_VERSION VERSION_GREATER_EQUAL 6.8)
                    qt_standard_project_setup(REQUIRES 6.8)
                endif()
                
                qt_add_executable(MyApp WIN32 MACOSX_BUNDLE)
                
                qt_add_resources(MyApp "configuration"
                        PREFIX "/"
                        FILES
                        qtquickcontrols2.conf
                )
                
                add_subdirectory(src)
                include_directories(${ORACLE_INCLUDE_DIR})
                
                include(FetchContent)
                FetchContent_Declare(
                        QXlsx
                        GIT_REPOSITORY https://github.com/QtExcel/QXlsx.git
                        GIT_TAG        v1.4.8
                        SOURCE_SUBDIR  QXlsx
                )
                FetchContent_MakeAvailable(QXlsx)
                
                set_target_properties(MyApp PROPERTIES
                        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                        MACOSX_BUNDLE TRUE
                        WIN32_EXECUTABLE TRUE
                )
                
                target_link_libraries(MyApp PRIVATE
                        Qt6::Charts
                        Qt6::Core
                        Qt6::Gui
                        Qt6::Qml
                        Qt6::Quick
                        Qt6::Sql
                        QXlsx::QXlsx
                )
                
                include(GNUInstallDirs)
                install(TARGETS MyApp
                        BUNDLE DESTINATION .
                        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
                        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                )
                
                if (BUILD_QDS_COMPONENTS)
                    include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents)
                endif()
                
                include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules)
                
                if (LINK_INSIGHT)
                    include(${CMAKE_CURRENT_SOURCE_DIR}/insight)
                endif ()
                
                set(QML_IMPORT_PATH ${PROJECT_BINARY_DIR}/qml CACHE PATH
                        "Path to the custom QML components defined by the project")
                
                qt_generate_deploy_qml_app_script(
                        TARGET MyApp
                        OUTPUT_SCRIPT deploy_script
                        MACOS_BUNDLE_POST_BUILD
                        NO_UNSUPPORTED_PLATFORM_ERROR
                        DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
                )
                
                install(SCRIPT ${deploy_script})
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  That's not exactly minimal.

                  If you want to debug that issue you should start with something really minimal that only uses the SQL module to ensure that nothing else is interfering and then add things gradually back.

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

                  Y 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    That's not exactly minimal.

                    If you want to debug that issue you should start with something really minimal that only uses the SQL module to ensure that nothing else is interfering and then add things gradually back.

                    Y Offline
                    Y Offline
                    Yihua Liu
                    wrote on last edited by
                    #9

                    @SGaist Hi, the following CMakeLists.txt is minimal, just add sql module in find_package() and target_link_libraries() based on the default CMakeLists.txt template of Qt Creator

                    cmake_minimum_required(VERSION 3.16)
                    
                    project(QtTest VERSION 0.1 LANGUAGES CXX)
                    
                    set(CMAKE_CXX_STANDARD_REQUIRED ON)
                    
                    find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Sql)
                    
                    qt_standard_project_setup(REQUIRES 6.5)
                    
                    qt_add_executable(appQtTest
                        main.cpp
                    )
                    
                    qt_add_qml_module(appQtTest
                        URI QtTest
                        VERSION 1.0
                        QML_FILES
                            Main.qml
                    )
                    
                    # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
                    # If you are developing for iOS or macOS you should consider setting an
                    # explicit, fixed bundle identifier manually though.
                    set_target_properties(appQtTest PROPERTIES
                    #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQtTest
                        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                        MACOSX_BUNDLE TRUE
                        WIN32_EXECUTABLE TRUE
                    )
                    
                    target_link_libraries(appQtTest
                        PRIVATE Qt6::Quick Qt6::Sql
                    )
                    
                    include(GNUInstallDirs)
                    install(TARGETS appQtTest
                        BUNDLE DESTINATION .
                        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
                        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                    )
                    
                    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