visual studio 2013 deploy a project - c++

I crack my head already, I need to deploy a project. I tried to use InstallShield, it create an msi file, and local installation has no errors, but then when I tried to launch the program it output "debug error". In my settings code generator -> runtime library set for Multi-threaded Debug DLL(/MDd). If I'll set it to Multi-threaded (/MT) it would not compile: "Please use the /MD switch for _AFXDLL builds"
Then I tried to use VS Installer project extension. It creates the msi and setup file, but after I install it, I can't find the .exe file and launch program. What I am doing wrong?
Folder with project files
![enter image description here][3]
Folder with exe file
![enter image description here][4]

At the stage of creating the installer for your program, you have to put all the external files, libraries and resources, that your program needs in order to run correctly, in your program's working directory. When you run the program via Visual Studio, everything works fine since it can find the files, because, as you've mentioned, they are in the project folder, and the project folder is where Visual Studio is looking for them.
When you launch your program outside VS, the program can't find these files since it by default tries to locate them in the folder in which the .exe file being run is located. So, if you wan't to run program outside VS, you need to put all the files needed to your .exe's directory.
For the same reason, while creating your installer, you need to include all the files necessary in the installation target directory together with your .exe. Every installer creator lets you do that.
In general, if you cannot run your program outside any IDE, and you can run it within that IDE, it is a rule of thumb that you should first check if you have included all the necessary files/libraries/dll's/etc. in your program's working directory.

I solved it!!!!!!!!
1)Help to run .exe file, helped updating .uld file in the same directory as a exe file.
2)I used Dependency Walker (http://www.dependencywalker.com/) to find all dll that it's need. And then I create a Setup Project using Wizard at the "Choose file to include" step I add every file and every library that it's depend on! Build->Install-> Then magic, and my application installed and running! Thank you all for your help

Related

Qt C++ Application deployment problems, used Visual Studio 2019 to create it

I just Build my Project and now when i click the executable file (.exe), i gives errors that some .dll files are missing, so i referred this page https://doc.qt.io/qt-5/windows-deployment.html which says that i can use Windows Deployment Tool, which is found in QTDIR/bin/windeployqt folder directory, but when i go to the path in the image c\Qt\5.14.1
i see that i have all these folders and all of them have bin folders, so to solve this i i went into visual studio , Extensions->QT VS Tools-> Qt options and this thing shows up ,where i got to know the version i am using
so, i opened command prompt and did this
After that, in my applications .exe folder, i see some more .dll files being added, but still i get the same errors
missing Qt5Widgets.dll,Qt5Core.dll,Qt5Gui.dll, i have all of those but the name ends with d, should i try renaming them ?
I have solved this by placing qt.conf file in my application's .exe folder
[Paths]
Prefix=C:\Qt\5.14.1\msvc2017_64
Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.

Building a Qt executable in Visual Studio 2017

I made a Qt Application in Visual Studio and it works when I run it in the program. However then I build the solution and try to run the executable errors pop up that certain .dll files are not found(QtWidgets.dll, QtCore.dll,QtCored.dll etc.). How can I fix this?
To make your application ready for deployment, you can use windeployqt.
It is a commandline program that comes with Qt and collects all the required dependencies of your executable. Go to your QTDIR/bin/ folder and run this command
windeployqt <path-to-app-binary.exe>
It will scan your binary and copy everything that is needed next to it. For further details, have a look at the documentation.
Well, you have two options:
If you want to distribute your application, you have to copy the required DLLs to the folder where your executable is. You can do this either by copying them manually or you write a script for this. The DLLs are in the binary folder of your Qt installation, e.g.
Qt\5.12.2\mingw73_64\bin
Add the above mentioned folder to your system PATH variable, then the DLLs should be found by your application.

Qt application release exe not running

I have built a very simple calculator in Qt. When I run it in release mode from qt creator, everything works fine. However when I go to the release folder and run it, it gives QT5Core.dll, QT5Widgets.dll and QT5Gui.dll not found. After running windeployqt there by:
windeployqt .
All the dll get added. However, it then gives error VCRUNTIME140_APP.dll and MSVCP140_APP.dll not found. After copying them to the folder. The exe doesn't give any error on double clicking but just does not start. What should I do?
I found this solution here, however I cannot find any qml file in the application directory.
I created it as a QT widget application. I am using Windows 10 with Visual Studio 2017 and MSVC2017 64bit desktop kit. The application is in C++.
Update:
Running the command
windeployqt Calculator.exe
after adding qt to the path seems to do the trick. Application working even after removing qt from the path. Will try running the app inside vm just to be extra sure.
When running from the command line, add your Qt Bin directory to the PATH. For example:
C:\> PATH=C:\Qt\Qt5.11.0\5.11.0\msvc2017_64\bin;%PATH%
You can solve the problem as selbie described it. An another way is to copy the missing .dll-Files to the folder where the.exe is placed.
See here https://doc.qt.io/Qt-5/windows-deployment.html#creating-the-application-package :
To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
set variable VCINSTALLDIR, example:
set VCINSTALLDIR=p:\Programs\Microsoft Visual Studio\2017\Community\VC\
and next run
windeployqt.exe app.exe
Or copy vc_redist.x64.exe from Redist subfolder into folder with your application.
As #mosa mentioned, To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
To add missing .dll files first open QT MSVC Console and type windeployqt.exe command,
Then you have to go to the directory which .exe file contains. Let's assume my .exe is in the desktop,
C:/
cd user/indrajith/desktop
Then you can add missing .dll files using following command,
windeployqt.exe --quick.
Finally, just double click your .exe file to run the program.
Simple Solution:
Copy "bin" and "plugins" folders from the qt setup directory(C:\Qt\6.2.4\mingw_64) to your release folder.
Put your .exe file inside that "bin" folder and done.
Now, your .exe application should run.The bin and plugin folders contain required .dll files and unnecessary files can be removed manually.

visual studio 2013 modify path variable when running .exe

I have compiled an exe file in Visual Studio 2013, and it depends on some external files to function. I want to keep those files in the same folder that the exe is in. When I run the .exe by clicking on it in file explorer, it loads the files fine. However, when I run it from Visual Studio, it is unable to run because the PATH variable does not include the directory with the necessary files. How can I configure my project to run the program with a modified path variable so that it can access the files properly?
As far as I understand you question correctly. I suspect that this is an issue related to the different directories when you execute. In Visual Studio (to my knowledge), you have a folder named Debug and a second folder named Release.
You may choose in Visual Studio to run the program in either debug or release mode. But you might not have the required files neccessary in both directories.
For example:
I've made a program that reads "Hello World!" from hello.txt, and displays this in the dialog window as a string.
If I store the file in the Release directory, the executable will run fine outside the IDE, when just launching the executable file.
However, if you run the application in debug mode through the IDE (Visual Studio), the program will not find the neccessary file. The program is looking for the file in it's current directory (Debug).
A quick fix to this is to copy the required files to the current working directory. Eventually have a duplicate set of files in both directories at all times.
Hope that I did understand you correct, and that my answer helps you. :)

Build project package C++ Builder

I have written a GUI forms application in C++ Builder and am wanting to be able to run the .exe on another computer.
I am getting some .bpl errors when trying to run the .exe on another computer.
How can I combine all the required files into a 'package' such that the .exe can be run on computers that do not have the required files?
I have done Project->Deployment and a list of files have appeared, including the .bpl file. However, what do I do from here?
thanks
Your .exe has dependancies on external .bpl files that you have not distributed to the other machines. If you want the .exe to be self-contained so you do not need to distribute those files, go in to the Project Options and disable both the "Use dynamic RTL" and "Build with runtime packages" options.