I want to statically link Qt libraries to my program so that It can run in my school computer.We don't have purmision to install anything on those computer thus statically linking is my only chance .
So far this is my cmake file
cmake_minimum_required(VERSION 3.9)
project(Calculator)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -std=gnu++14 -no-pie -fPIC -static -lQt5Widgets -lQt5Gui -lQt5Core")
find_package(Qt5Widgets REQUIRED)
include_directories(/usr/include/qt/QtWidgets /usr/include/qt /usr/include/qt/QtGui /usr/include/qt /usr/include/qt/QtCore /usr/include/qt)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
add_executable(${PROJECT_NAME} main.cpp calculator.cpp resources.qrc calculatestring.cpp )
here is what I get when I try to run this cmake file:-
/bin/ld: cannot find -lQt5Widgets
/bin/ld: cannot find -lQt5Gui
/bin/ld: cannot find -lQt5Core
if I remove -static
flag ,it compiles fine but only runs on machine on which qt is installed.
when I try to run it on my VirtualMachine with Arch Linux which doesn't have qt installed it give me error:-
error while loading shared libraries : libQt5Widgets.so.5: cannot open shared file: No such file or directory
I want(have no other choice) to run my program run without installing Qt on those machines .
Edit:-
Question likened as Possible Duplicate shows how to link with Qmake. I am using cmake .Also my question is not limited to the Qt.