How to change dll location to subdirectory in Codelite? - c++

Im using Codelite IDE and build test.exe gui application. When i started application i got error that some dlls missing. I found all that dll and put in folder where is test.exe, and all is working now. But with all that dlls there is mess in main folder.
How to move that dlls to sub directory so application still work, except i add that folder in PATH?

You need to change the PATH environment variable
To make it work in CodeLite, add line similar to this from: Settings->Environment variables
PATH=$PATH;C:\Path\To\My\Dll\Folder
Ofc, replace C:\Path\To\My\Dll\Folder to the actual path where you want your DLLs to be placed
Eran

Try this work-around:
Right click to your project - settings - general.
Change the "Executable to Run / Debug" to:
$(ProjectPath)/$(IntermediateDirectory)/$(ProjectName)
Change the "Working Directory" to:
$(ProjectPath)/YOUR DLL DIRECTORY

Related

DLL's dependency cannot be found when DLL moved to another location

I'm on Windows 10, Visual Studio 2017, x64 build . . .
I have a DLL that I'm using in an exe project. We'll call it, myLibrary.dll. It comes with a .lib companion file as well. The myLibrary.dll has some other DLL dependencies that it is using. We'll call that one theDependency.dll.
I've linked the companion myLibrary.lib file in my project through Linker --> General --> Additional Library Dependencies properties. Added myLibrary.lib to the Additional Dependencies.
When I build my project, I use post build event to copy the myLibrary.dll to the Release/Debug directory of my project.
This works fine.
My issue is when I try to use myLibrary.dll in a different exe project. I get an error that it cannot find the theDependency.dll. I've used all the same property setup as the first exe project. As a test, I moved the build directory of the first exe project to another location (on the same computer) and I get the same error. "Cannot find theDependency.dll"
How is myLibrary.dll targeting it's dependencies? Not sure why the 2nd project gets this error? Also, not sure why moving the files gets this error?
Any ideas? Thanks.
Adding the path of the dll to the PATH environment variable worked for me.

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.

Qml program does not run

I've build qt for static linking to make just one exe without any dll's, configured creator. On my computer everything works. But when i run a program on other computers nothing happens. Process starts, but nothing is shown. And it's only with qml, it works with c++ projects.
I tried to make a simple exe and add all needed libraries by windeployqt, but it doesn't change anything.
Maybe someone can tell me, what am i doing wrong?
I have found that with QML applications you might need directories from the following directory:
..\Qt5.3.2\5.3\msvc2013_opengl\qml\
The directories needed depends on what you have included.
For my application I had the following structure:
my.exe
QtGraphicalEffects
QtQuick
QtQuick.2
First run the mingw on cmd terminal of windows (on my case it is on C:\Qt\6.1.1\mingw81_64\bin).
After this go to your project output (where is your .exe file that you want to run on another windows machine).
Run the windeployqt command:
windeployqt.exe --qmldir C:\Qt\6.1.1\mingw81_64\qml .
I run the example project "Qt Quick Application - Scroll".
The blank screen only happens on PCs that do not have a video card with OpenGL 2.0 support.
Try this:
1. Used dependency walker(http://www.dependencywalker.com/) to see the exact path of the dlls needed. Try it because both QtCreator and QT framework both have the same dlls and you must pinpoint the exact ones used. I copied all dlls needed in the same folder as the app.
2.I have copied the folder platforms from QT framework /plugins and copied it in the same folder as the app. Now the app comtained also plugin/platform/ folder with all its dlls
3.And the most important step in my case is to create a file named qt.conf in the same folder as the app . This file should contain the path to the plugins. My qt.conf file contains:
[Paths]
Libraries=../lib/qtcreator
Plugins=plugins
Imports=imports
Qml2Imports=qml
Try copying every DLLs in below folder to the folder where your exe is.
C:\Qt\x.x.x\msvc20xx_xx\bin\
If the exe runs normally, try deleting the DLLs some by some to find out what dll is needed and what is not needed.

How to make .exe file in Qt Creator

I was working on Qt Creator compiler to make a simple text editor. I did that but now want to make an .exe file of that project, but I don't know how to make an .exe file in Qt Creator compiler. Can anyone help?
There is a tool that adds the .dlls automatically on windows.
In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).
Run windeployqt.exe in the command prompt with your project location as the argument like this:
windeployqt.exe C:\project_folder\my_project.exe
Now my_project.exe will have the .dlls in the same directory and will execute.
The executable is generated by the compiler when you build your application. To know where the executable is stored, look into
Projects (CTRL+5) -> Build settings -> General -> Build directory
This is where Qt creator will put the .exe it generates if you have shadow build enabled.
If shadow build is disabled, the executable will be stored inside the project folder itself.
From:
How to create executable file for a Qt Application?
Basically you have to look for MinGW subfolder deep into Qt tree, where Qt utilities reside, and copy needed dll's.
These are the steps I follow, based upon Qt 4.7.4, for packaging the application with correct shared libraries.
Let's say you've installed Qt under c:\qtsdk.
Open your project, and compile it in release mode.
Go to this directory: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin -- it contains all shared libraries. Debug libraries end with a "d" -- frex, QtCore.dll is release version, while QtCoreD.dll is debug version.
Copy at least these files into your release directory (where your .exe lies):
mingwm10.dll
libgcc_s_dw2-1.dll
QtCore4.dll
QtGui4.dll
I just built, tested and deployed a dummy project this way.
I had the same problem so I used the suggested above answer:
"
There is a tool that adds the .dlls automatically on windows.
In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).
Run windeployqt.exe in the command prompt with your project location as the argument like this:
windeployqt.exe C:\project_folder\my_project.exe
Now my_project.exe will have the .dlls in the same directory and will execute.
"
but there somethings that I did so this might help:
there is already an executable version of your app in the debug file of your project if you can't find it try to enter properties in Qt creator an track down the file. while you are at it in properties you can also see whether your app is using msvc2017_64 like in the previous answer or other compilers.
Take that file to the same path you write in the command line here: windeployqt.exe C:\project_folder\my_project.exe.
when your try to open the executable file it will till it needs some dlls files that you can find in this path .\Qt\5.9.1\msvc2017_64\bin copy and paste them in the location of the exe file
Steps to make an exe file from your qt project
In Build Settings make sure Edit build configuration is Release.
In Build Settings uncheck Shadow build(this will make sure that the release folder is inside of your project directory instead of outside of your project directory).
Build and run you project(This will create a release directory inside of yours project folder).
Copy *.dll and *.exe file from C:\Qt\6.3.2\mingw_64\bin to the release folder (where your projects exe file is there).
Copy all folders from C:\Qt\6.3.2\mingw_64\plugins to the release folder.
Now you can launch the exe file inside of your release folder corresponding to your project.

Project cannot load image assets while running from visual studio IDE

I am porting an old visual studio C++ project. I have a data folder in the project directory that contains all the image assets. The project is build using an external make file.
My problem is, the project cannot load the asset files while running the executable from the VS IDE during debugging. However, if I execute the exe from bin folder, it can load the assets.I am assuming there are some kind of environment issue in the project, but could not figured it out.
Any clue?
My guess is that the program tries to access the assets using a relative path like ..\data\some.data. It works when you run it manually from the bin folder, because the current directory is set to the bin folder itself (the folder from where an application was launched) by default.
But when running projects from the Visual Studio IDE, parameters set under "Project properties > Debugging" tab apply instead. There is an option "Working directory", which defaults to $(ProjectDir), i.e. the folder where the project file resides.
Try changing that to the bin folder, or, if the resulting .exe file is placed directly there, easily just to the $(OutDir) variable.