exe file is not running in Release folder - c++

My project IDE: Visual Studio 2019, Qt 5.15.0.
I'm trying to launch the application by the project_name.exe file of the release build, but nothing happens.
The project_name.exe file of Debug mode is running well.
The project is running well also in IDE in both Debug and Release modes.
I added Qt Bin directory to the PATH.
I tried windeployqt command but it didn't help.
I copied to Release folder all the dll files the application depends on, according to the build output and Dependencies tool, but then I couldn't run it neither from the exe file nor from the IDE (there are no any compilation errors or error messages when I'm trying to run it).
What is missing for running the exe file from Release folder?

The following steps finally solved my problem:
Copy the qml folder from the project directory into Release folder (it has to be
near the exe file).
In Release folder launch Command prompt and write: windeployqt project_name.exe,
this step must come after having qml files for getting the whole needed deployment
files by windeployqt command.
Copy from your system the following dlls into Release folder: opengl32.dll,
libcrypto-1_1-x64.dll.
For a VM with no Visual Studio installed there are some more dlls to copy.

Related

Qt visual studio building

I have ms visual studio solution with qt project. When I working from visual studio all works fine. When I try to run *.exe file from building folder I see message that say Qt5Guid.dll(and other dll's) is not found.
What settings need to be changed that QT dll's moves to general building folder ?
You can find in Qt installation dir application windeployqt.
Run it like this:
windeployqt --debug <path-to-app-binary>
It will deploy all needed Qt files to your application's folder. You can read more about deploying here: https://doc.qt.io/qt-5/windows-deployment.html
Also you can try to add directory of Qt to PATH variable
(Thanks king_nak and drescherjm)

Not able to run C++ application built with VS2017 on another machine where VS2017 is not installed

I have VS2017 installed on windows 10 machine and I am building my C++ code in it. when build success I am able to run that exe on same machine. But when I am copying that exe (with all dependent DLL's) on another winodws 10 machine where VS2017 is not installed its giving error "The code execution cannot proceed because urctbase.dll was not found".
I copied those dll's (ucrtbase.dll vcrutime140.dll etc.) at the same location where exe resides and try to run it then its giving error "The application was unable to start correctly(0xc700000b). Click OK to close the application"
I installed VC Redistributable-2017 package to setup run time environment on that machine, but problem persists.
Can anyone help to resolve this issue?
it's difficult to get all the dependent DLLs of your program. I suggest you create setup project that can detect all these dependencies:
0- Put your project in release mode
1- install Microsoft Visual Studio Installer Projects from here
2- Add setup project to your VS solution
3- Add your program to the setup project
4- Choose primary output of your project
5- As you can see, visual studio detect all dll dependencies

Creating Visual Studio Project from CMake, Visual studio does not find executable

Basically, I've got the same question as in
How to configure CMake so that the generated Visual Studio project finds the executable?. None of the answers there worked for me.
I have a CMake project, and I just want to create a Visual Studio 2019 Project from it:
So I just run cmake . from the root directory.
Then I have a *.sln file in my root directory.
After opening it with Visual Studio 2019, I press the "Local Widows Debugger" button, it compiles successfully but then the IDE complains with:
Unable to start program 'C:\Users...\x64\Debug\ALL_BUILD'. The system is unable to find the specified file.
Using travis everything compiles fine, too: https://travis-ci.com/Necktschnagge/markov_chain_analyzer/builds/144941090
You can see the code here: https://github.com/Necktschnagge/markov_chain_analyzer/tree/old
What do I need to do so that CMake creates a VS solution, that is well-configured so that I can run the debugger?
When you create a Visual Studio solution with CMake, it automatically sets the Startup Project to ALL_BUILD. This is a CMake pre-defined target, which builds all of the projects in the solution. It is not a project containing an executable that can be debugged.
You must change the Startup Project in your Solution Explorer to one of your executable projects before debugging. You can do this by right-clicking on the project you want to debug, and selecting Set as Startup Project. There are some more instructions here if you're using VS with CMake integration.
You can also tell CMake to set a different Startup Project by default when building CMake from scratch, using VS_STARTUP_PROJECT. Put something like this in your top-level CMake file:
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT MyExeTarget)
Now, CMake will set MyExeTarget as the Startup Project in Visual Studio, instead of ALL_BUILD.

Embed Resource Files into C++ Executable

I'm running into a strange issue when I compile a release package for a C++ application I am writing for work. Inside the IDE(Visual Studio 2017 Community Edition), when I compile and run the application, it runs fine and finds the missing resource file. When I compile with the IDE, go into the file manager, go to the output directory, and try to run the compiled EXE, I run into an error that says "Failed to load icon from the file 'foo/bar/dumb.ico' (error 2: the system cannot find the file specified.)'
Is there something I need to do with my IDE so the resource files are embedded into the EXE so I can distribute them around the office?

How can I run qwt examples using Visual Studio 2010?

I'm trying to run Qwt examples using VS2010. I've installed the Qt plugin for Visual Studio. I then open the .pro file of Qwt and the build succeeds. But I have no clue what to do next. Whenever I click run, it gives me a dialog which says
unable to start programe E:\qwt-6.0.1\src..\lib\qwtd.dll
Does anyone have an idea what might cause this?
I just managed to get the examples compiled using the command line tools. Key steps included:
Add the bin dir of qt and the lib dirs of qt and qwt to the path
Dont forget to run vcvars32.bat from Visual Studios bin directory
VC\bin should be in the path too
then follow the INSTALL instructions from qwt
After this I had a set of running examples in examples/bin of qwt. It's also easy to open one of them in Developer Studio with the "Open Qt Project File" option in the Qt Menu.
From the information you're giving us, it seems you have the project generating your DLL set at the StartUp project. So whenever you click on run/debug, it will try to run the output of that project, in this case a DLL. Of course this won't work.
If there is a project for the example you want to run, right click on that project within the Solution Explorer and select "Set as StartUp Project". Now when you click on run/debug, it will run the output (the executable) of the project you selected.