Using BOOST_STACKTRACE_USE_BACKTRACE on Windows with MinGW64 - c++

I am building a Qt application using Windows and MinGW64. I need to use Boost Stacktrace to generate stack traces like the Linux build of the application already does.
The corresponding switch BOOST_STACKTRACE_USE_BACKTRACE (as described in https://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace/configuration_and_build.html) is set and everything works fine on Linux.
However on Windows the libbacktrace library is missing. The above boost page contains two links to the sources of libbacktrace but I couldn't find a prebuilt binary for Windows/MinGW nor could I find any build instructions or usage documentation for my environment.
How can I use BOOST_STACKTRACE_USE_BACKTRACE with Windows/MinGW64?

I solved this problem (and some more issues) by switching to MSYS2 UCRT. MSYS2 provides a precompiled libbacktrace package.

Related

How to build a Qt C++ application that doesn't need VC Redistributables on a pc to run

I am building an application using Qt C++ and I want it to run on windows computers without having to install VC Redistributables. Apparently when user tries to run the application an error pops that says that VCRUNTIME140.dll is missing.
Build both Qt and your application using compiler option /MT?
https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170
I recommend using GCC (i.e. MinGW) as the compiler. If you do that, your app will generall depend on the msvcrt.dll that comes with Windows and doesn't need to be installed specially (but it depends on exactly how the GCC compiler is configured). It will also possibly depend on some GCC runtime library DLLs that you can just put in the same directory as your EXE.
MSYS2 is a good development environment for using MinGW on Windows: https://msys2.org
I also made a useful set of tools that is capable of cross-compiling statically-linked MinGW/Qt applications from Linux: https://github.com/DavidEGrayson/nixcrpkgs
The Qt applications I build with nixcrpkgs come out as single, standalone EXEs that do not need to be shipped with any DLLs.

Make - Internal compiler Error under QT 5.14.2 "Q_CORE_EXPORT"

I just installed QT Creator with QT under Win10 to build an already existing project. (Under Ubuntu everything went fine running the Make file). I'm not an expert for QT therefore I'm not able to find out how to resolve the error:
C:\Qt\5.14.2\mingw73_64\include/QtCore/qfloat16.h:102:54: internal compiler error: in make_rtl_for_nonlocal_decl, at cp/decl.c:6590
Q_CORE_EXPORT static const quint32 mantissatable[];
My gcc version is 8.3.0 (x86_64-posix-seh, Built by strawberryperl.com project). Is there something missing or broken in the installation?
On windows, you generally need to have a Qt which was built with the same (or compatible, but that can be hard to verify) compiler and relevant build options, as what you are using to build your application.
I doubt you will find a pre-built Qt SDK for that version of gcc, so if you want to use it, you should build Qt from sources. It can be a bit tedious on Windows, there are a fewf prerequisites you have to get etc. I recommend you use the Qt online installer to install a MinGW version of Qt SDK, and matching version of MinGW (also offered by the Qt installer.
I just found out from qmake.stash, that the included script for creating the make file always referenced a false path for the gcc compiler. I therefore build i manually with the QT Creator and it worked as expected. So I guess the fault was due to different paths for gcc in the environmental variables.
Here is the bug, there is a link to the patch: https://github.com/msys2/MINGW-packages/issues/5006
Also you can just downgrade to mingw gcc 8.2.0

std::mutex missing when building Qt app with MXE gcc

I'm attempting to get a Qt application to build from the command line under linux targetted for windows. I've used mxe to build a toolchain for targetting windows but my build fails whinging about various thread related bits. mxe built with winpthreads and I know the Qt project will build on windows itself from inside of creator, using the pre-packaged mingw compiler. I'm successfully building using my ARM Linux cross compiler, so I just want to get windows done the same. I'm trying to get a one line build on a build server or from Jenkins for all my targets.
I'm guessing I'm missing something that I need to pass to mxe when doing the cross toolchain build or alternatively missing something I need to pass to qmake for this build to succeed.
The issue is with the default MXE build of GCC using win32 threads as opposed to mingws pthreads implementation.
Edit src/gcc.mk and ensure that winpthreads is added to the $(PKG)_DEPS list and then change the configure line so that --enable-threads=win32 becomes --enable-threads=posix.
Then re-make winpthreads and gcc. Note that there is a circular dependency here, you need to build gcc with win32 threads (the default) first THEN remake with winpthreads.
Thanks to Andreia Gaita for this - http://blog.worldofcoding.com/2014/05/cross-compiling-c11-without-going-madder.html
POSIX configuration was added to MXE (Building pthreads inline with gcc and enable optional posix threads in libgcc).
For example, to build qt with that (x64, shared, posix threads):
make MXE_TARGETS='x86_64-w64-mingw32.shared.posix' qt

Build ZBar for 64bit WIndows

The ZBar library is distributed with a 32bit binary lib file and dll. I need to use ZBar in a 64bit Windows application. It seems that the only way to get 64bit version of ZBar is to build it yourself.
According to this faq, the only way to build ZBar is by using MinGW. I also found this patch for patching ZBar in order to produce a 64bit build.
Of course I can try to follow these suggestions and try to build ZBar, but since I have never built ZBar before, and I don't know MinGW at all (I am a VC++ user), I was wandering if anyone has built a 64bit version of ZBar for Windows successfully. Maybe there is even someone that can share the binaries with the rest of us. Any suggestion is welcome!
Thanks.
Since there were no answers I assume that there is no available 64 build. I therefore decided to do it myself. Since I don't know MinGW and the link from the zbar faq seems to be broken, I decided to build using VS2013.
The code for the VS2013 project and the adapted ZBar code can be found in https://github.com/dani4/ZBarWin64. I also added the built libraries themselves. See the README for details.
I am new to github so possibly my choice to change a fork of ZBar wasn't the right one, and I should have created a new repository. Anyway I think that the library can be used in this form as well.

How do I set up OpenCV for MinGW project?

I regularly use Code::Blocks and MinGW for my C/C++ projects. I would like to be able to use OpenCV, since it has a nice library for computer vision projects. They have dropped support for MinGW. I have heard you can build it on your own somehow, but I have no experience doing this with 3rd party libraries. Can someone explain how to build it in a simple way for MinGW?
There is, or at least there was at least until 2.4.6, precompiled version of opencv that works out of the box with mingw as long as you use the dw2(standard) version of mingw.
since i needed sjlj support i had to build my own version of openCV 2.4.6
I did he following - i am pretty sure it will work for the current openCV version as well
Setup your preferred Mingw Environment - i would strongly recommend to use gcc 4.5 or newer
Intstall Msys
Intall Cmake - you can get a binary package
Start the Cmake GUI
Select the openCV source folder
Click Configure and select MSYS-Makfiles
Errors in the first run of Configure might be resolved if you run Configure again
Click Generate
use MSYS make to run the generated makefile
Copy all desired libraries and include files to your mingw-installation or your project