Building 32bit libraries opencv - c++

I recently downloaded and built opencv in my 64-bit Windows machine using cmake. All the binaries are included in the install folder and it contains only the folders as shown below:
I don't know how to config cmake to produce binaries for x86. I'm asking this, because I'm using Qt Creator 32bit with MinGW and I'm getting problems while linking and compiling the code. What's the proper way to do the build? I'm using mingw compiler suite.
Note: The downloaded package contains the pre-built binaries for x86 but there are none for MinGW, but only for Visual Studio.

Steps for mingw from with cmake-gui from this guide. We could also do this easily on command prompt with cmake and -m32 option. But using cmake-gui will give you more idea about the options available for opencv configuration and bring you in better position if you want to customize opencv build tomorrow ( like enabling java wrapper or OpenCL etc ).
Start cmake-gui.
Set source path to downloaded opencv directory and build path to your choice as in image
Click Configure button and specify generator as mingw makefiles as
in image
Choose compilers ( here we choose 32 bit ) as in image and click Finish button.
An options page will be listed.
5.1. Edit CMAKE_INSTALL_PREFIX to change the install location if you want to.
5.2. Select ENABLE_CXX11 if it isn't already selected.
5.3. Change other options only if you are familiar with them. Then click Configure again and then click 'Generate` to generate make files.
Modify opencv\sources\modules\videoio\src\cap_dshow.cpp and add this define at the top of the file:
#define STRSAFE_NO_DEPRECATE
In command prompt( at build path ) type mingw32-make ( add mingw32-make folder to PATH if required )
On completion, type mingw32-make install

Related

Using VCPKG with cmake and Qt 6 for Windows ARM64

Qt 6.2 introduced Windows on Arm support (https://bugreports.qt.io/browse/QTBUG-85820). I tried to create a new cmake project set up using Qt Creator and everything works fine. Then I wanted to add some external packages to my project using vcpkg. The standard way to use vcpkg with cmake is using the CMAKE_TOOLCHAIN_FILE variable (as mentioned here. However, when I clicked on project settings in Qt Creator (Projects > Build) it seems that Qt Creator has already set up the CMAKE_TOOLCHAIN_FILE variable to another file
Presumably, this is done so that it is possible to cross-compile an ARM64 binary from a x64 machine. However, this prevents me from setting up vcpkg within my Qt project. Is there a way to get around this issue? Does CMake support multiple toolchain files or is there an alternative setup for my scenario?
I found out that VCPKG provides a way to achieve this as explained here:
To use an external toolchain file with a project using vcpkg, you can set the cmake variable VCPKG_CHAINLOAD_TOOLCHAIN_FILE on the configure line:
cmake ../my/project \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=../my/project/compiler-settings-toolchain.cmake
So in my case, I can just qt toolchain file using VCPKG_CHAINLOAD_TOOLCHAIN_FILE option.

How do I build Qt 3.X.X on Windows?

I downloaded a project that depends on Qt 3.X.X (legacy version). I downloaded this version from the Qt downloads archive and set the environment variables according to what the documentation tells me. I can't build the program though. The errors I get are all along the lines of
Moc'ing SomeFile.h ...
The system cannot find the path specified.
Looking into the Qt /lib folder, there's just one README file that says
If this directory is empty, you forgot to build the Qt library
I'm assuming this is the reason I can't build my project, so I would like to know how to build this Qt version. The documentation is extremely limited since it's an old version, so I can't get it to work based on that.
Some system info:
Windows 10
x64
Visual Studio 2015 installed
If you need more info, please let me know!

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

Unable to build for Windows on Linux, with MinGW

Because I am not a Java enthusiast, I decided to use C++ and Qt for one of my projects. However, I came across the big cross-compiling Qt problem, and I am unable to produce an .exe file for Windows users.
My setup
Linux Ubuntu 12.04, with Wine and Qt. qmake -v gives the following output :
QMake version 2.01a
Using Qt version 4.8.1 in /usr/lib/x86_64-linux-gnu
I also have a MinGW32 compiler, which can be found at /usr/bin/i586-mingw32msvc-g++. My Wine drive_c folder contains the following Qt directories :
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/Src
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32
The mingw48_32 directory contains the necessary include/ and lib/ directories, which are used in my mkspec file, /usr/share/qt4/mkspecs/win32-x-g++/qmake.conf :
QMAKE_INCDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/include
QMAKE_LIBDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/lib
The problem
According to most guides I've found about Qt cross-compiling, my setup should be enough to run a simple :
qmake -spec win32-x-g++
make
wine /path/to/my/application.exe
But... nothing's linked. QApplication and every other symbol I use in my program are "not found". No QApplication, no QPushButton, no connect(), no SIGNAL(), no SLOT()...
My objective here is to successfully configure QtCreator to use this setup (in an independent build configuration), so that it can build a Linux executable (through the first and working configuration), and a Win32 .exe (through the MinGW setup above). However, I cannot modify a single build step in QtCreator :
Cannot add a "MinGW" toolchain : it is not available in the "Add" dropdown list.
Cannot change the -spec parameter value in the project build configurations panel. The field is non-editable.
Despite guides and solutions I found all over the Internet, my only solution so far is to send my source code to a virtual Windows machine, and have it create a new project with it. On this VM, I could probably compile for Windows... But of course, this doesn't actually sound like a real "solution" to me...
Is there any way Qt(Creator) has finally made cross-compiling easier now ? I'm getting a bit tired of "symbol not found" errors...
First,
sudo apt-get install mingw-w64
Then, check if Qt Creator finds the toolchain.
Next, until Ubuntu starts providing a mingw-w64-qt package, download the Qt source and build it. This is bound to get messy, and maybe even the simplest thing to do is to install WINE and use a Windows Qt version.

instructions on building CGAL libraries from source code

I have installed Computational Geometry Algorithms Library 4.3 and followed instructions on CGAL4.3 manual page(http://doc.cgal.org/latest/Manual/installation.html).
After I cmaked CGAL-4.3 folder , it says ,"make # build the CGAL libraries".However I cant find any cmake command or .exe file to execute "make".What am I missing here?
below I copied the instructions on the manual page in case anyone cant access it.
1 Introduction
This document describes how to install CGAL on Windows, Unix-like systems, and MacOS X.
Ideally, setting up CGAL amounts to:
cd CGAL-x.y # go to CGAL directory
cmake . # configure CGAL
make # build the CGAL libraries
You are on windows so you may not have make.
You can either install make or tell Cmake to generate something else than a makefile (like a Visual Studio project for instance).
If you are using Cygwin, it should be pretty easy to install make or maybe you already have it. Try typing make at the Cygwin prompt.
From my limited experience building code on windows, I recommend installing MinGW and Code::Blocks. Then ask Cmake to generate a Code::Blocks project using MinGW. Open the project and build it. Clean and easy.
Note that the CGAL Project provides Installation Instructions for Windows