I wrote a little Qt program (on Windows) and I met the following situation:
With CMake, I generated my make files to build the Program as follows
cmake_minimum_required(VERSION 3.5)
project(helloworld)
SET(C++_STD_FLAG "c++11" CACHE STRING "e.g. c++98,c++11,c++14,...")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${C++_STD_FLAG}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets)
add_executable(main main.cxx)
target_link_libraries(main Qt5::Widgets Qt5::Gui Qt5::Core)
If I want to start the "main.exe", it appears a message that some DLL's are not found. The DLL's are Qt5Widget.dll, Qt5Core.dll, Qt5Gui.dll. If I copy them to the same folder as the "main.exe" everything work fine.
How can I launch the "main.exe" without copying the DLL's into the directory?
EDIT: The path, where the DLL is, is already added to the PATH variable in windows. However, it does not work.
EDIT: I also append my code of the main.cpp
#include <QtWidgets>
#include <QApplication>
int main(int argc,char **argv){
QApplication app(argc,argv);
QWidget window;
window.setWindowTitle("Hallo Qt");
QPushButton *button = new QPushButton("Ende");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(button);
window.setLayout(layout);
window.show();
return app.exec();
}
EDIT: I found the problem, but this raise a furhter question: I also have installed PyQt, which had a higher priority in the PATH variable. So I made the other Qt installation a higher and it worked.
But, How can I tell an executable file to use a specific DLL? Because, if I compile the program with Qt Creater it works even if the PyQt has a higher priority in the PATH variable.
Thanks in advance