Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building project with Qt #72

Open
Simzy opened this issue Jan 24, 2022 · 18 comments
Open

Error building project with Qt #72

Simzy opened this issue Jan 24, 2022 · 18 comments
Labels
Howto Guide & Tutorial

Comments

@Simzy
Copy link

Simzy commented Jan 24, 2022

image
As you can see, i keep getting the error for building no matter which version ive tried using your files and was wondering if i have done something wrong somewhere

@OrGoN3
Copy link

OrGoN3 commented Jan 25, 2022

Because you have to remove the $PWD in the beginning of your openssl lib paths. Also, point to the main openssl folder (OpenSSL_mingw64), not the lib.

I still cannot build this even after following directions. I tried the Qt 6.x branch, 5.15.15, 5.12.12, etc. Even if I tried to build from the 5.0 release commit, it still errors.

@eliboa
Copy link
Owner

eliboa commented Jan 25, 2022

I made a tutorial to set up Qt and build the projet : https://www.eliboa.com/NxNandManager_Set_up_and_build_project_with_Qt.pdf

@OrGoN3 what errors ?

@Simzy
Copy link
Author

Simzy commented Jan 25, 2022

followed the guide but when trying to make an actual executable that i could move to my flash drive it doesnt want to do it, https://puu.sh/IESRh/a2fc380301.png that is the latest attempt at building and the difference between release and debug, i can get it to run and show a gui if i just use the run command in QT creator but only in debug not release even though i have added the CONFIG+=ARCH64 CONFIG+=DYNAMIC to both just to test it

@eliboa
Copy link
Owner

eliboa commented Jan 25, 2022

Did you copy the dokan1.dll inside the release build folder (in my case build-NxNandManager-Desktop_Qt_5_13_0_MinGW64_Dynamic-Release) ? As you did for the debug folder when you followed the guide.

Also, you'll need to deploy the project if you want to run the program outside Qt's environment (Qt Creator), a.k.a put all the required DLL's in the same folder as your executable :

@eliboa
Copy link
Owner

eliboa commented Jan 25, 2022

Also, don't forget to ALWAYS run Qt Creator as an administrator because NxNandManager will try to elevate rights at startup.

@Simzy
Copy link
Author

Simzy commented Jan 25, 2022

I think i am on the right track, but im still getting warnings appearing in QT Creator https://puu.sh/IEVNf/96281bef8b.png

@eliboa
Copy link
Owner

eliboa commented Jan 25, 2022

You don't need to care about warnings. Your build is fine, you should be able to run it anyway.

@Simzy
Copy link
Author

Simzy commented Jan 25, 2022

Yeah it runs, im guessing the reason all the dlls are in the folder are linked to it being a dynamic build? either way i appreciate the help youve given.

@eliboa
Copy link
Owner

eliboa commented Jan 25, 2022

Yes, you would have to make a static build of Qt to get rid of all these dlls, but it's no piece of cake believe me!
DLLs are dynamic libraries to be linked to your application at compile-time. They are only loaded into memory at run-time. Instead, static libraries are embedded inside the executable at compile-time.

@OrGoN3
Copy link

OrGoN3 commented Jan 25, 2022

I made a tutorial to set up Qt and build the projet : https://www.eliboa.com/NxNandManager_Set_up_and_build_project_with_Qt.pdf

@OrGoN3 what errors ?

I'm getting the same warnings but then I'm always getting an error at the end. I will redo it soon and post back. Thank you for your support. I'm just trying to build the latest version to use. I'll report back and I'll use the setup from your guide.

@OrGoN3
Copy link

OrGoN3 commented Jan 26, 2022

@eliboa

So I was able to successfully build based on your explicit directions. I copied dokan1.dll to the correct folder. I added "--gui", selected to run in terminal, and disabled qml debugging, as your picture shows. I built in debug. When I attempt to run, Application output is

19:57:40: Starting C:\dev\NxNandManager\NxNandManager\build-NxNandManager-Desktop_Qt_5_13_2_MinGW_64_bit-Debug\debug\NxNandManager.exe --gui...
19:57:40: C:\dev\NxNandManager\NxNandManager\build-NxNandManager-Desktop_Qt_5_13_2_MinGW_64_bit-Debug\debug\NxNandManager.exe exited with code -1073741515

If I don't run it in a terminal, I get an error popup

The code execution cannot proceed because libcrypto-1_1.x64.dll was not found. Reinstalling the program may fix this problem.

UPDATE: I noticed there was an environmental path for OpenSSL_mingw64/lib, but not OpenSSL_mingw64/bin. So I added one for the /bin and it worked.

My question is, why did I have to do this extra step?

I compiled a release version. I added it to the NxNandManager4.0 zip folder you shared with us here. I added dokan1.dll. It needed QT5Network.dll. I then took the dll's from the mingw version I was using and copied them into that folder. The program now runs.

Thank you for all of your help.

The question that remains is why did I have to manually add the OpenSSL_mingw64/bin/ folder to the running environment path in QT Creator to run the program?

The new question is, can you share the procedure you used to statically link everything and to release a single exe as you have with version 5.0? Or is that too much to ask/unfeasible?

Thanks again for all of your support, @eliboa !!!!!

@eliboa
Copy link
Owner

eliboa commented Jan 26, 2022

I'm glad it worked out for you both 👍

@OrGoN3 I'm guessing the reason you had to add ".../OpenSSL/bin" to your environment variable $PATH is because "libcrypto-1_1-x64.dll" was missing from NxNandManager.exe directory (or a bad version of the dll). This DLL is the only one needed from OpenSLL/bin folder.

When an application linked to a DLL is launched, the system will try to locate the DLL file in the same folder as the executable. If not found, it'll scan every path listed in the system env. variable $PATH (can be overloaded by Qt Creator at run-time).
If you intent to share a copy of your build with someone else, the easiest thing to do is to put all the DLLs in the same folder as your executable.

Now if you want to use a static version of Qt, you need to compile it yourself first. Every "official" Qt kit is a collection of pre-built libraries to be linked dynamically. What you need to do is to recompile all QT source code from scratch. You can follow this guide : https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW.
Depending on your CPU, the process can take a very long time (several hours maybe), so if you want I can send you a copy of my "Qt 5.12.9 Static kit" for intel I64 CPU. Just let me know.

In NxNandManager project, the only lib that can't be built statically is Dokan, therefore dokan1.dll is mandatory.

@OrGoN3
Copy link

OrGoN3 commented Jan 26, 2022

I'm glad it worked out for you both 👍

@OrGoN3 I'm guessing the reason you had to add ".../OpenSSL/bin" to your environment variable $PATH is because "libcrypto-1_1-x64.dll" was missing from NxNandManager.exe directory (or a bad version of the dll). This DLL is the only one needed from OpenSLL/bin folder.

When an application linked to a DLL is launched, the system will try to locate the DLL file in the same folder as the executable. If not found, it'll scan every path listed in the system env. variable $PATH (can be overloaded by Qt Creator at run-time). If you intent to share a copy of your build with someone else, the easiest thing to do is to put all the DLLs in the same folder as your executable.

Now if you want to use a static version of Qt, you need to compile it yourself first. Every "official" Qt kit is a collection of pre-built libraries to be linked dynamically. What you need to do is to recompile all QT source code from scratch. You can follow this guide : https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW. Depending on your CPU, the process can take a very long time (several hours maybe), so if you want I can send you a copy of my "Qt 5.12.9 Static kit" for intel I64 CPU. Just let me know.

In NxNandManager project, the only lib that can't be built statically is Dokan, therefore dokan1.dll is mandatory.

Thank you so much.

As for libcrypto not being in the folder, correct it wasn't. But it was linked from the open ssl folders you provided. I assumed it would link to that by itself or build/copy from there.

Basically, I'm wondering why I had to add to the build path and the other guy here didn't. Was I supposed to manually copy this or did my build mess up?

Yes please do send me that. At Gmail is my address. I would like to attempt to build this statically.

Thanks again! You are very helpful and patient!

@eliboa
Copy link
Owner

eliboa commented Jan 26, 2022

I updated the guide. Cf. the "Static build" part at the end. Let me know if something is missing or not working.

@eliboa eliboa pinned this issue Jan 26, 2022
@eliboa eliboa changed the title Error building latest version Error building project with Qt Jan 26, 2022
@eliboa eliboa added the Howto Guide & Tutorial label Jan 26, 2022
@sofakng
Copy link

sofakng commented Jan 31, 2022

I'm not sure if I should add my question here or create a new topic, but I'm trying to compile a static build and I'm getting a few errors:

:-1: error: error: C:\Qt\Tools\mingw810_64\x86_64-w64-mingw32\lib\libdwrite.a: No such file or directory
:-1: error: error: C:\Qt\Tools\mingw810_64\x86_64-w64-mingw32\lib\libglu32.a: No such file or directory
...
:-1: error: error: C:\Qt\Tools\mingw810_64\x86_64-w64-mingw32\lib\libuser32.a: No such file or directory

I was able to build the dynamic version and followed the instructions for the static build but I'm obviously doing something wrong.

I'm not sure why it's looking for \mingw810 when it should be using \mingw730 ?

@eliboa
Copy link
Owner

eliboa commented Jan 31, 2022

@sofakng you're not doing anything wrong, Qt Tools also have some libs to be built statically, I just forgot to add them in archive.
dl & extract this archive into C:/ and let me know how it works : http://eliboa.com/QtToolsStatic_for_mingw810_64.rar

@Simzy
Copy link
Author

Simzy commented Apr 16, 2022

i decided to give the static version a try for the latest update and this is what happens for me https://puu.sh/IV6bE/fdd9a3eae1.png

EDIT:
It also asks for the qtnetwork5.dll when i do build non-static and putting it in from the install folder https://puu.sh/IVhD5/2b5fc3c4ee.png is what happens when i add it in

EDIT 2: So using the dll files from 4.0 release as a template, i decided to try copying the same dll files from C:\Qt\5.13.2\mingw73_64\bin (the version i used to compile) and it works now without any issues, i guess Qt is just like windows and is picky about file versions.

@eliboa
Copy link
Owner

eliboa commented Apr 21, 2022

@Simzy Did you manage to build a static version after all ?
From your first screenshot It look's like your "Static 64" kit is using a dynamic Qt Version. Can you send me a screenshot of your "Qt Versions"

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Howto Guide & Tutorial
Projects
None yet
Development

No branches or pull requests

4 participants