Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5 CMake include all libraries into executable
Forum Updated to NodeBB v4.3 + New Features

Qt5 CMake include all libraries into executable

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 452 Views 1 Watching
  • 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.
  • V Offline
    V Offline
    Vildnex
    wrote on last edited by
    #1

    I'm trying to build a with Qt 5.14 an application on release mode and everything is working fine inside of Qt Creator, but when I'm trying to run the executable by itself I'm getting an error like this:


    OS: Windows 10

    Qt: 5.14

    Cmake: 3.5


    enter image description here


    What I've tried:

    1. set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
    2. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fPIC")
    3. ${ADDITIONAL_LIBRARIES} -static inside of target_link_libraries

    None of the above worked for me and I'm getting the same error whenever I'm trying to run the executable by its self without using Qt Creator.


    My CMake file:

    cmake_minimum_required(VERSION 3.5)
    
    project(Scrollable LANGUAGES CXX)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
    set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -std=c++0x -fPIC")
    set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt5 REQUIRED Core Widgets Gui Qml Quick Qml)
    
    qt5_add_resources(resource.qrc)
    
    include_directories(${CMAKE_CURRENT_SOURCE_DIR})
    include_directories("MoviesInterface")
    
    set(SOURCES
            main.cpp
            MovieInterface/movieinterfaceomdb.cpp
            MovieInterface/moviesinterface.cpp
            )
    
    set(HEADERS
            MovieInterface/movieinterfaceomdb.h
            MovieInterface/moviesinterface.h
            )
    
    
    add_executable(Scrollable ${SOURCES} ${HEADERS} qml.qrc)
    qt5_use_modules(Scrollable Core Network)
    target_link_libraries(Scrollable
            Qt5::Core
            Qt5::Gui
            Qt5::Widgets
            Qt5::Qml
            ${ADDITIONAL_LIBRARIES} -static
            )
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      To execute your application outside of Qt Creator, you have to deploy it using windeployqt.

      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
      1

      • Login

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