Why have .a files been installed in Windows with Qt online installer? - c++

I installed Qt 6.3.1 libraries pre-built with MinGW 11.2.0 64-bit using the online installer. The application crashes without entering the main function when I use any of Qt libraries in the Qt Creator while there is no problem if I use only C++ standart library. I guess the problem is in linking. Because I realized that there are .a files in the folder C:\Qt-mingw\6.3.1\mingw_64\lib, even though I am using Windows 10. Why are .a files installed instead of .lib files? How to solve this issue?
Here are the the selections that I made when installing Qt libraries using the online installer:

After learning that the problem may be due to duplication of some library from here, I saw using dependency walker that my program uses libstdc++-6.dll in system32 instead of qt-mingw installation. So the problem solved when I copied that dll into my app's folder. But I wonder how to solve this by changing the path without copying libstdc++-6.dll into app's folder. Because even though I put qt-mingw bin folder at the very beginning in system path, app uses still the one in system32.

Related

How do I get the static versions of the modules?

I'm working on a game in SFML. It runs correctly on my computer, but if I send it to another computer then when I try to run it I get errors about not being able to find libraries. I did some research and I found that the reason is because I was using dynamic libraries, and to get the program to work on its own I need the static libraries. But how do I get those? They aren't in my sfml folder. I tried doing more research but I can't find a way to build or download those libraries.
Just go to your sfml Src directory and look for the /bin folder. Copy the following DLLs to your game folder where your exe is located:
DLLs
sfml-graphics.dll
sfml-window.dll
sfml-audio.dll
sfml-network.dll
sfml-system.dll
On Linux, install libsfml-dev on target computer.
I am sure you are using mingw compiler. You can add static arguments and try.
-static-libgcc -static-libstdc++
If this doesn't work try to search the two DLL files in your standard compiler path /bin folder and place them where your exe is located.

How to run a Qt Program without Qt itself being installed?

I have written a program with Qt5.3.1 and run it on my development machine where it works fine. I copied all necessary .dll files into the folder where my .exe is. These are:
Qt5Widgets.dll
Qt5Network.dll
Qt5Gui.dll
Qt5Core.dll
icudt51.dll
icuin51.dll
icuuc51.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
libstdc++-6.dll
Now I want to run that program on a machine that has no Qt installed. How do I do that? It shouldn't be necessary for users to install an IDE just to use a program, right?
Details of the development machine where it works:
Windows 8
Qt 5.3.1
The deploying platform is:
Windows Vista
No Qt installed but all necessary .dlls are in place
Errors I get are first:
This application failed to start because it could not find or load the Qt platform plugin "windows".
Reinstalling the application may fix this problem.
Next error message is:
This application requested the Runtime to terminate in an unusual way. Please contact support.
Then the program crashes. But if I install Qt5.3.1 it works. So it has something to do with files in the c:/Qt directory
This application failed to start because it could not find or load the Qt platform plugin "windows".
For this problem, you should copy the plugin {QTSDK}/plugins/platforms/qwindows.dll to {YOUR_EXE_DIR}/platforms/qwindows.dll.
The short answer is you either need to do a static build, or you need to redistribute the Qt shared library DLLs. If you're looking for a smaller file size static builds are often better, but there may be legal implications with this approach if you're using Qt5 under a LGPL license. I'm not a lawyer, but you can read about LGPL linking rules in LGPL section 4.1.
The long answer is you should read the general Qt5 deployment guide and the Qt5 for Windows deployment guide. These go into quite a bit of detail.
A better solution is to use the Qt SDK application "windeployqt". It is used to copy all the required dlls and plugins to your application folder based on target platform. You can then run that on another computer. Here is the documentation: https://doc.qt.io/Qt-5/windows-deployment.html.
For example, if your executable was built using mingw53_32 and your executable is in "C:\example_qtapp":
QT_INSTALL_DIR\minqw53_32\bin\windeployqt.exe c:\example_qtapp
I have encountered this problem as well,
In your Qt Directory, with the proper Qt version
C:\Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\platforms\
copy qwindows.dll into a new folder that lives next to your executable, such that your list would be
Qt5Widgets.dll
Qt5Network.dll
Qt5Gui.dll
Qt5Core.dll
icudt51.dll
icuin51.dll
icuuc51.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
libstdc++-6.dll
platforms/qwindows.dll
You should place Qt DLLs along the release version of your executable. These are Qt5Core.dll, Qt5Gui.dll and possibly the ones for other modules that you have used. These dll files are in your installed Qt Directory in bin folder. You should also place LIBGCC_S_DW2-1.DLL, MINGWM10.DLL and LIBSTDC++-6.dll in case you are using MinGW.
If you are using plugins you should place their dll in a folder named plugins beside your exe. In case of using icons and images you should ship their dlls like qico.dll and qsvg.dll in a folder named imageformats.
if Qt dlls are there, they it should work. My guess is that you are missing the run time libraries/dlls of your IDE. For example, if you are using Visual Studio 2010 as your IDE, then you need to install VS2010 Redistributable x86/x64 link depends on your architecture.
You should also copy {QTSDK}/plugins to directory where you executable located. Then create qt.conf in the same place (with executable) with the following content:
[Paths]
Plugins=plugins
Thеn, run your program. I did the same on linux.
In your application folder hold down SHIFT key and right click from mouse.
You will see - Open command window here
Click Open command window here
TYPE windeployqt.exe app_name.exe --parameters and HIT ENTER
Example:
windeployqt.exe APP_NAME.EXE --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-angle --no-opengl-sw

No DLL dependency Mingw under Netbeans

I'm trying to get back to C++ using Mingw and Netbeans but all released .exe requires some .dll files if ran on another PC.
What should I do to add those library to the released .exe file. [I do not have too much experience in real C++ programming]
Please tell us what dll's are missing. but often you can find them in the bin folder of mingw. If you release your program, put those dll's where your exe is.
Alternative: use static linkage
Edit:
You can get this file from the bin folder of your mingw installation. Copy it to your exe
Compile with linker flags: -static-libstdc++ and -static-libgcc

Using libcurl without installing it

How can I use libcurl with my project without actually installing it or curl on the system?
I want to make my source-code portable, so that any developer can copy the folder with all sources and other files, run make and compile the program without the need for system level installations.
I am looking for (probably separate) solutions for Linux and for Windows (dll?). If it is possible, provide some standard/official solution and not hack (I'd like to be educated about linking third party libraries)
I've used it on Windows using Visual Studio, all you need to do under Windows:
Download the source
Using CMake generate the project files (when using Visual Studio).
Build the libraries, 3 files will be built: libcurl.lib, libcurl_imp.lib and libcurl.dll
Include curl.h in your project and add the paths to your .lib files
Build your program, put libcurl.dll in the executable folder and it will work.
On Linux it should be a similar process, build the libraries and include them with your source.
You probably want to build a static library out of libcurl and link agains it. Should be pretty straightforward and the process is almost identical on every OS.

Compiling libpng and using it with netbeans and mingw

I have only previously used visual studio for developing c++ but I've just moved to netbeans and am having some issues.
I got mingw installed so that my projects will compile but I dont know how to add external libraries to that. I want to use a static library, not a dll.
The library I specifically am looking at is libpng
I hope this isn't too IDE specific, I'm also looking to know how to prepare the library.
Windows OS.
I figured it out more or less. I used the cmake gui, configured for msys make and mingw g++ and gcc, on the zlib source directory and then ran msys make and make install on the output directory. After that I did the same on libpng, but I had to add some variables to point to the zlib include and library directories within cmake.
Then in netbeans, I right clicked>>properties on my project and added include and lib location for each of the two libraries. I also could have copied the files into my mingw directories.
Now I'm just stuck with this issue.