Crash when run in Release mode?
-
@Mucip it's not that the .dll is missing - it's just not accessible to the release image. (I'm probably not the best one to explain this.) This would be a useful experiment: go into your build directory for your debug build. Find the executable and try to run it (this should work). Then go into the build directory for your release build, and do the same thing. I'm expecting you'll get an error message from the binary; if so, please post it.
-
Dear @mzimmers ,
Well, I tested in DEBUG directory. Clicked MriERP.exe file. Ofcourse it says LimeReport, QtZint and QtCore and etc files are missing. When I copy these files in the debug directory I can run the program in DEBUG folder.When I try same thing in RELEASE folder, error messages are the same. Same files are missing. I copied LimeReport, QtZint and Qt's DLL files than MriERP.exe files worked normally too.
A quick question: If some DLL are missing It shouldn't compile the project, should it?...
Regards,
Mucip:) -
Thanks for running those tests. I misspoke when I said the debug version should run; I forgot that the libraries aren't available outside of Creator. Since you probably don't intend to run your debug version outside of Qt, that's not important.
To fix your release build, you need to do (at least) two things:
- tell Creator which files (the ones you mentioned)you want to copy to your build directory. This can be done like this (in your .pro file):
my_release.files = "libexpat.lib" my_release.path = $$OUT_PWD INSTALLS += my_release
- in your build settings, you need to add a step after make, to do a make install. This will copy the files for you.
This should not work, but might not be exactly what you want. The user can run your program out of the release directory, but if he moves the executable, it won't run. If this presents a problem, let me know, and I'll tell you how to fix this (but it will take you some time to do so).
-
@mzimmers said in Crash when run in Release mode?:
my_release.files = "libexpat.lib"
my_release.path = $$OUT_PWDINSTALLS += my_release
Hi,
How can I put two dll files in the my_release.files? Should I add path also?By the way, what is changed after Qt 5.13.2? I didn't make this modification before? Why it happend in Qt 5.14.2?
By the way if I copy LimeReport.dll and QtZint.dll to RELEASE folder, I can run the program in Qt Creator. This mean the problem was LimeReport.dll and QtZint.dll files missing!
But why? It was working in Qt5.13.2 before???
Regards,
Mucip:) -
target.path = $$OUT_PWD target.files = "LimeReport.dll" "QtZint.dll" INSTALLS += target
This link OUT_PWD will explain how it works.
Just make sure to add the install step to your build. Adding this stuff to the .pro files is just specifying what the install will work on.
I can't answer why it worked in 5.13.
-
@mzimmers said in Crash when run in Release mode?:
target.path = $$OUT_PWD
target.files = "LimeReport.dll" "QtZint.dll"
INSTALLS += targetHi @mzimmers,
I copied above lines in my pro file and add make step to build like below picture. But still same crash?!
I affraid I could not copy dll's to destination folder. :(
Where am I wrong?...Regards,
Mucip:) -
@mzimmers ,
No. Files did not copied in the folder. But when I add below string than everything solved. I can run program in release mode too.target.path = $$OUT_PWD target.files = "D:/Belgeler/Qt/LimeReport/win64/release/lib/LimeReport.dll" "D:/Belgeler/Qt/LimeReport/win64/release/lib/QtZint.dll" INSTALLS += target
Thanks...
Regards,
Mucip:) -
Excellent. If you like, you can create a variable in your .pro file for your directory that contains the libraries, and use that variable when specifying the target.files. Won't change the behavior; it's just a bit cleaner.
If you think this is resolved, please mark the topic as solves using the topic tools available in your first post in this thread.
-
@SGaist said in Crash when run in Release mode?:
@Mucip That is something that you can find out in the release notes as well as in the git history.
But whatever the differences are, I seriously doubt they have anything to do with the problem you encountered. More likely, when you updated, you also created a new .user file that wiped out your build settings.
-
Hi @mzimmers ,
Let's suppose there is report folder in the main project directory and some xml files in this report directory. I want to copy report folder and contents to the target directory too. Above information I can copy files to target but what about create folder and copy files to target directory on compile time?Regards,
Mucip:) -
@mzimmers ,
I got it thanks.
Maybe someone has same problem. I solved like below.
The code create "rapor" folder and copies contents to target build directory.target.path = $$OUT_PWD/release target.files = "D:/Belgeler/Qt/LimeReport/win64/release/lib/LimeReport.dll" "D:/Belgeler/Qt/LimeReport/win64/release/lib/QtZint.dll" $$PWD/rapor INSTALLS += target
Regards,
Mucip:) -
@Mucip said in Crash when run in Release mode?:
If some DLL are missing It shouldn't compile the project, should it?
If they are missing at compile time then yes it will not compile.
But in your case they are missing at runtime.
QtCreator prepares the environment before starting your app, so it can find all libraries.
If you want to start your app outside of Qt creator you need to deploy it first: https://doc.qt.io/qt-5/windows-deployment.html -
-
If the above tips haven't helped, here's another: I had a bug in a function that should have returned a bool (but returned nothing) that caused the project release version to crash while the debug version ran OK. After adding the missing line of code both versions ran.
Regards,
theldl