how to compare two image using mingw64 gcc/g++? - c++

I need compare two image using mingw64 gcc/g++.
I tried https://github.com/huihut/OpenCV-MinGW-Build
but not compiled my source code.
test.cpp:1:9: fatal error: opencv2/core/core.hpp: No such file or directory
#include<opencv2/core/core.hpp>
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
how to compile and compare two image using mingw64 gcc/g++?

First thing: you cant do such tasks with "MinGW gcc/g++" this is only a compiler. What you ment is hor to do such thing with C or C++ which are programming languages.
You already found a project yourself but there are some dependencies you dont have in your posted message it is OpenCV have a look at their Release page their also seem to be some precompiled windows binaries. Install this library and try again and see if you got all dependencies. Or better: always read the readmes often they tell what you need to build the projekt.

Related

How do I add the wxWidgets library to use in Code::Blocks?

I'm pretty new to C++ and I'm having a hard time trying to install external libraries. I want to get started with GUI programming and I have searched all over, but I cannot find a way to add wxWidgets to Code::Blocks. I've tried a few different guides and Stack Overflow responses but none of them have actually worked.
I'm using this 'Hello World!' test program to see if it works, every time I try to run it I just get this error: fatal error: wx/wxprec.h: No such file or directory. I can't seem to figure out how to tell Code::Blocks where the library is.
The most recent resource I have tried is this one, I followed it step by step, but still I got this error.
What linker/compiler settings do I need to use in Code::Blocks? What lib files do I need to add and where do I add them to? Do I need to build the .zip file? How do I do this?
Please could I get a step by step guide on exactly how to add wxWidgets (or indeed any external library) to Code::Blocks as well as some information on why certain things are required?
Here's what I tried
Following the steps in the link above, this is what I have in my build options:
I tried adding this in my global compiler settings...
I still have this error...
CodeBlocks seems to have some special wxWidgets integration, but it didn't always work for me, so I prefer to set up the project manually.
CB ships an outdated compiler. While it may work, updating it is a good idea.
Get rid of the MinGW version shipped with CB, or at least remove it from the PATH.
Install MSYS2. Use it to install a new GCC and GDB, as described in the link.
Configure CB to use MSYS2's GCC and GDB, by specifying the paths to them in the CB config (they're installed to C:\msys64\mingw64\bin).
wxWidgets seem to ship prebuilt libraries for MinGW, but since we're using MSYS2, we might as well use the version provided by MSYS2.
Use MSYS2 to install wxWidgets: pacman -S mingw-w64-x86_64-wxWidgets3.2-msw.
MSYS2 seems to ship several different versions of wxWidgets: 3.0, 3.1, 3.2, and each of them in two variants: -msw and -gtk. 3.2-msw looks like a reasonable choice to me, but I haven't used this library before.
wxWidgets doesn't seem to use the standard way of telling you what compiler flags to use (which would be pkg-config, or at least a CMake file). Instead they ship their own script to determine the flags, called wx-config.
Run wx-config --cflags to get the compiler flags, and run wx-config --libs to get the linker flags. Paste them into the project settings (compiler settings and linker settings respectively). Edit the project settings, not the global compiler settings.

fix: too many sections (52187) - Cmake, Qmake

I need to compile a C++ program on Windows using the CLion IDE with CMake and Qt Creator with QMake.
On Linux, I do not get any problems at all.
On Windows, I wanted to use the MinGW compiler. My source code relies on boost. Therefore, according to this question, I was installing the compiler from the MinGW Distro.
So far so good. Now, during the compilation process I get the following error:
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/as.exe: CMakeFiles\[...]: too many sections (52187)
C:\Users\MATTHI~1\AppData\Local\Temp\cc2TyXHu.s: Assembler messages:
C:\Users\MATTHI~1\AppData\Local\Temp\cc2TyXHu.s: Fatal error: can't write 231 bytes to section .text of CMakeFiles\[...]: 'file too big'
after some research, (here and here) I found out that heavy templating might be the reason for this issue... However, I do not do any templating at all, but I'm including the Eigen libraries that might cause the issue.
In any case, I need to fix this and the proposed solution is to add the following flags to my compiler:
-Wa,-mbig-obj.
My question now is: how can I do this in my IDE (CLion or QtCreator) or in my CMakeLists.txt (CMake) and/or myProject.pro (QMake) files?

In C++, what is wx.h?

The existing code is calling some sort of wx header file and my DEV C++ compiler just says there's no such file.
Code:
#include<wx/wx.h>
Compiler error:
[Error] wx/wx.h: No such file or directory
So my question is -
What is wx.h
How do I install it in my compiler so that I can use it?
Do I need to change my compiler or DEV C++ would do fine?
What is wx.h
It is the header file of a library. The GitHub project should have some instructions on how to fetch the dependencies and how to install them.
How do I install it in my compiler so that I can use it?
Normally you have to download the dependency, build it (following some instructions), and then you need to use the header in your project and link the library. The exact steps depend on each library and each compiler.
Do I need to change my compiler or DEV C++ would do fine?
In principle, no. Some libraries only work with some compilers, though.
Note that Dev-C++ is not a compiler, it is an IDE that comes with a port of GCC (as far as I know).
It seems that you are using WxWidgets framework but your compiler doesn't know where to find its headers, and apparently also libs which you would face with on a next step.
You, need to add to your compiler flags the output of wx-config --cxxflags. And also to your linker flags the output of wx-config --libs.
Assumption is of course that WxWidgets is installed on your PC

Compiler error in mingw-w64: 'undefined reference to `__getreent.'

I'm currently in the (nightmare) task of trying to compile cImg and libjpeg in Windows. After many hours, I was finally able to build libjpeg and I've included it within the build process (cImg needs libjpeg to work with jpegs).
When I try to compile with 'g++ image.cpp libjpeg.a -lgdi32' I get the following error:
'jerror.c:112: undefined reference to `__getreent. The system cannot find the path specified.'
I've had a look on google but there doesn't seem to be many people with the same issue (and fewer still with answers).
I'm compiling in windows using mingw-w64.
I've solved this. For anyone who has the same problem:
Make sure that you are compiling libjpeg.a and cImg with the same compiler (i.e. gcc or mingw-w64)
Due to difficulties compiling libjpeg with mingw-w64 i used the gcc compiler but if you are using this library you need to compile cImg with gcc as well (which causes other issues...)
I eventually managed to compile libjpeg with mingw-w64 in MSYS2 by changing the Path. To do this you need to inherit the Windows Path - edit 'msys2_shell.cmd' and remove 'rem' from 'set MSYS2_PATH_TYPE=inherit'

I'm lost in boost libraries (specifically boost_program_options)

Hi all I've been banging my head against the wall all day now.
So I want to move my program onto the university supercomputer, but it doesn't have boost (and I used boost program_options in my code). On my pc, I just have -lboost_program_options and that works fine, but obviously won't work anymore.
So, I need to package the necessary stuff along with my code so that it will compile on the supercomputer (using intel icpc)
My first hurdle was compiling the line in my makefile that had the code that wanted to include the boost header, but I ran the following in my code folder:
bcp --scan --boost=/usr/include/ main.cpp destination_folder/
And put the resulting files in my include directory. which solved that.
Boost program options isn't a header only package unfortunately, so i need something else. I need to get a library or something. Because i get errors when the compiler gets to the last task on my makefile (doing all the object files)
In my travels I found this question:
extractin/building boost program_options
I tried what the answer suggests, but putting "build" in my command doesn't generate any extra files...
Now totally stuck, don't know how to get this library thing. I've read so much stuff on bjam my head is spinning, I just don't have the level of understanding to process it all in my head.
OS: Linux both systems
One option is to build boost on that machine. Install it in your home. Change your CXXFLAGS and LDDFLAGS to point to the proper header and library directories and build your code there.
The other option is to cross compile both on your PC (if you have such a cross toolchain). Link your code statically to boost and take the final binary to the super computer.
Since both systems are linux, you'll just want to use the binaries. If both systems run on the same CPU, just compile your program statically. If not, download the debian package for the architecture your supercomputer runs on and rip headers and binaries from that.
I've build boost from bjam for cross-compiling to windows, and if there ever was a reason to use the autotools in a project, it's the mess of boost and bjam. Avoid it if possible, and try to adapt the debian package source if you can't.
Instead of building Boost.ProgramOptions you could include and compile all its .cpp files within your project.