Can't run First Program
-
Hi there,
I am trying to run my first Hello World program with Qt. And it's being a true nightmare.
I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.
IDE is VSCode.
The main file I try to build and run is test.cpp:
#include <iostream> #include <iterator> #include "neuron.h" #include "accessory_functions.h" #include <QtWidgets/qapplication.h> #include <QtWidgets/qpushbutton.h> int main(int argc, char **argv){ QApplication a( argc, argv ); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); hello.show(); return a.exec(); }and the tasks.json file to build the active file loos as follows:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-IC:/Qt/6.4.2/mingw_64/include", "-LC:/Qt/6.4.2/mingw_64/bin/", "-lQt6Widgets", "-lQt6Core" ], "options": { "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\" }, "problemMatcher": [ "$gcc" ], "group": "build", "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe" } ] }Now the buld runs fine. But when running the program I get the error:
"The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."
Well, files are obviously at the location the are presumed to be (-L location in the build call)
The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.
Any help is greatly appreciated.
Thanks in advance,
Carlos. -
Hi there,
I am trying to run my first Hello World program with Qt. And it's being a true nightmare.
I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.
IDE is VSCode.
The main file I try to build and run is test.cpp:
#include <iostream> #include <iterator> #include "neuron.h" #include "accessory_functions.h" #include <QtWidgets/qapplication.h> #include <QtWidgets/qpushbutton.h> int main(int argc, char **argv){ QApplication a( argc, argv ); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); hello.show(); return a.exec(); }and the tasks.json file to build the active file loos as follows:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-IC:/Qt/6.4.2/mingw_64/include", "-LC:/Qt/6.4.2/mingw_64/bin/", "-lQt6Widgets", "-lQt6Core" ], "options": { "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\" }, "problemMatcher": [ "$gcc" ], "group": "build", "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe" } ] }Now the buld runs fine. But when running the program I get the error:
"The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."
Well, files are obviously at the location the are presumed to be (-L location in the build call)
The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.
Any help is greatly appreciated.
Thanks in advance,
Carlos.@CarlosCz25 said in Can't run First Program:
Well, files are obviously at the location the are presumed to be (-L location in the build call)
Sorry I don't know about the "installer". But that
-Lis to be used while building a Qt executable. When you run the executable it always has to find the.dllfiles it needs, either alongPATHor in the same directory as the executable, hence yourThe curious thing is that if I start placing the dll files next to the build executable the error message changes
I don't know about "VS" stuff, but people usually use
windeployqtto package and deploy their programs (plus dependent DLLs). -
Hi there,
I am trying to run my first Hello World program with Qt. And it's being a true nightmare.
I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.
IDE is VSCode.
The main file I try to build and run is test.cpp:
#include <iostream> #include <iterator> #include "neuron.h" #include "accessory_functions.h" #include <QtWidgets/qapplication.h> #include <QtWidgets/qpushbutton.h> int main(int argc, char **argv){ QApplication a( argc, argv ); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); hello.show(); return a.exec(); }and the tasks.json file to build the active file loos as follows:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-IC:/Qt/6.4.2/mingw_64/include", "-LC:/Qt/6.4.2/mingw_64/bin/", "-lQt6Widgets", "-lQt6Core" ], "options": { "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\" }, "problemMatcher": [ "$gcc" ], "group": "build", "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe" } ] }Now the buld runs fine. But when running the program I get the error:
"The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."
Well, files are obviously at the location the are presumed to be (-L location in the build call)
The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.
Any help is greatly appreciated.
Thanks in advance,
Carlos.@CarlosCz25 Note that build path and running path are two different things. Do not mix them up. -L in tasks.json sets the lib path for build only. When your app runs, it looks for the libs in the environment paths.
-
@CarlosCz25 Note that build path and running path are two different things. Do not mix them up. -L in tasks.json sets the lib path for build only. When your app runs, it looks for the libs in the environment paths.
@JoeCFD
Hi Joe,great advise.
Adding the qt dll's path to the path variable did the trick.Many thanks.
Carlos.
-
C CarlosCz25 has marked this topic as solved on