Can't configure OpenCV with Qt properly? - c++

I'm trying to configure OpenCV (3.1) with Qt Creator on Windows 32 and 64 bit for a long time to create a GUI application but I just can't seem to solve this configuration part. I've tried and read a lot of tutorials there are on the internet (https://zahidhasan.wordpress.com/2014/08/19/qt-5-3-1-64-bit-mingw-windows/ for example) but with no success.
When I try to run my program, I'm getting these errors:
enter image description here

To use a library, you have to reference its headers (and that is what you have done correctly with your #include directives).
But you also have to point the linker to the location and names of libraries to link. That is currently missing in your configuration, because you get undefined reference errors from linker.
Hard to tell anything more without knowing more details on your setup so far.
Depending on your environment and the build of OpenCV you need, you need to configure your project to use static libraries or DLLs (I assume we speak about Windows here).
As you use imread(), you will surely need the opencv_highgui*.* library, but this will surely not suffice.
See e.g. this OpenCV documentation for a complete list of OpenCV libraries.

Related

How to create a portable executable with allegro 4.4.2

So I am creating a C++ program using the allegro version 4.4.2 library and I need to be able to produce an executable package which I can submit to a course instructor and have run on his computer without issues. I am developing the program using DevC++. If I am understanding this correctly so far, I need to link to a static library for allegro and then the executable should include the library info and thus the library itself is not necessary to have included in the executable package. I have also seen some recommendations regarding third party tools that produce executable packages, but these seem to be more general (not necessarily allegro compatible?) and I am hoping to avoid downloading more third party software.
I have tried linking to the static library liballegro-4.4.2-monolith-static-mt.a but for some reason when I do this I get a whole slew of undefined reference compile time errors. I have read that it is necessary to have #define ALLEGRO_STATICLINK included in the project, I have this statement at the top of my main source file but I am not sure if I am meant to define this somewhere in the project options instead?
Any guidance or link to resources which will help me solve my problem would be extremely appreciated! I am just getting into the meat of programming with C++ beginning to learn object oriented programming methods, I still occasionally struggle with the basics so thank you in advance for your help!
Backstory (if interested/relevant?): I am taking a Game AI programming course for which we need to create some example programs to demonstrate AI algorithms. The course specifies Java but I am most familiar with C++ and the course instructor says this is fine but I must be able to submit an executable to him which he can just run on his computer without issues. To best achieve what the course asks I feel the allegro library (which I already have installed) will be of great help, mostly for drawing graphics to the screen and such.
So I just ended up using a dynamically linked version of my program and including the appropriate .dll files which turned out to be a lot less work than I thought it would be.
Basically I just had to ensure the allegro-4.4.2-md.dll from the bin folder was included in the folder with the executable. I then sent off the package (the .exe compiled file and the needed supporting files such as bitmaps sound files etc) to a few friends and had them try to run it. They then gave me the warnings from their computers along the lines of "Test.exe cannot be run ****.dll cannot be found".
I searched the exact names of the dll files they were receiving warnings for in the folder with my game and voila it now seems to execute on whatever PC it is sent to.

How should/could/must I handle the dll that my C++ projects depend on?

I'm lost here and I have no clue how to proceed. This is not a question about how to make my program work, this is a question about how to stop wasting my time.
My programming environment is Visual Studio 2013 on windows, in C++.
I use 3 libraries extensively, namely: boost (using dynamic linking), OpenCV, and Qt.
During the development, I have configured VS to look at those 3 libraries by default for include and .lib. I have also added the 3 folders containing all the dlls to my PATH environment variable.
It works, but it is sometime painful, let me explain you when.
First hassle: Anytime I have a LNK error telling me I miss a function, it is usually on OpenCV since it has only one include file referencing all the functions. I have to look at OpenCV's source code to see what module this function belongs to and to know what I must link my program to.
Second Hassle: When comes the time to deploy my application, I have to ship it with all the relevant dlls. To know which one I need, I open dependency walker and try to forget nothing, I have then to test it on a different computer because 102% of the time I have missed a couple, and then I have to configure my Installer generator to include all those one by one.
Third Hassle: To ease a little bit the process of configuring a new development machine, I have recently switched to NuGet. It is great, I add boost with a couple of clicks to any project. But now my boost DLLs are everywhere, I have one folder per boost library, and since there are dozens of those I can't even add them all at once to my PATH now, so I have to move them manually to the appropriate folder, and that is really not what I want to do with my not-so-precious-but-who-are-you-to-judge time
I have looked around and couldn't find any good practice regarding this issue, maybe because they are too obvious, or too specific to a particular setup.
How do you do? How would you do if you were me?
We put all our external dependencies in version control along with the code. This ensures that all code can build "out of the box" on any of our development machines and also ensures that for any given version of the code, we know exactly which dependencies is has.
The best way to check for missing dependencies is how have a good automated test suite, if you've got comprehensive converge then if your tests pass you must have deployed the required libraries.
In terms of linking to the appropriate libraries, unfortunately, that just sounds like an issue with the structure of OpenCV (I'm not familiar with OpenCV). I tend to use dumpbin under Windows and nm under Linux to easily grep for symbols when I get link errors with an unfamiliar library.

FFmpeg development on Eclipse on Windows

The first thing I did was to refer to tutorial on FFmpeg site.
I set up MSYS+MinGW64, I cloned all the relevant pre-requisites (i.e OpenSSL, x264, rtmpdump),
I successfully cross-compiled them all. I ran the configure for FFmpeg, and I was able to cross-compile that as well. And my statically linked ffmpeg.exe works to my satisfaction.
In Eclipse I was able to create a project, load up the source code, navigate it, make some changes, even compile and step-through debug. The problem I am having is with the Eclipse design-time error, and I think this is more of an Eclipse/C++ thing than FFmpeg.
For example in ffmpeg.c I find this error "Field 'bitstream_filters' could not be resolved" at this line:
AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
that output_streams is of type
OutputStream **output_streams
and when I try to open the declaration for OutputStream Eclipse gives me the option of two locations. Obviously Eclipse is not sure which of these declarations it is, hence the "could not be resolved" error. OutputStream is defined in the following 2 files
ffmpeg.h
libavformat/smoothstreamingenc.c
(hmm nice to know FFmpeg can do smooth streaming...) but anyway the correct definition would of been the one in ffmpeg.h.
So... the whole goal of getting the source into an IDE was so that I could enjoy the benefits of such things like intelisense. What can I do in Eclipse to set some sort of order or rule as to how it should resolve types in cases where the names clash like this?

Can I use Win32 FreeType without the .dll file?

I'm teaching myself OpenGL and I'm implementing ttf text rendering using FreeType 2. I downloaded the library from
http://gnuwin32.sourceforge.net/packages/freetype.htm
and after a couple of minor issues I got it running properly. The thing that's bothering me is that I have to place a copy of freetype6.dll in the directory with my executable in order for the thing to run. I generally try to avoid a bunch of unnecessary dll files floating around. I'm sort of new to windows programming, but from what I understand most libraries can be built to run fully from a lib rather than requiring a dll at runtime. Looking through the documentation from FT is making my brain melt, so I thought I would ask here to see if there were any devs that have worked with FT before and if so, do they know how to build the library such that no dll is required at runtime.
Thank you in advance for any advice or support.
Check out this link. See the section Optional: Installing FreeType (by compiling it yourself)
Follow the instructions and you'll be good to go.
you can generate static lib by getting source code of it... then you won't need dll...and i think freetype2's source is available...
It is something DLL generic. All your DLLs should be in PATH similarly to LD_LIBRARY_PATH. Also under Windows (unlike Unix) the current directory is always in the PATH. So you just need to set your PATH variable to point to location of this dll.
Now, for Unix... you probably just have this library installed by default like hundreds of other useful libraries that are not present under Windows by default.
So... No unless you link statically you should use DLL somehow. And my suggestion - use dll.

C++ GUI Tutorial: undefined reference to TextOut

So after a bit of searching for Win32 GUI tutorials (I decided a tutorial on making GUIs might make me more active in making C++ applications and therefore stronger at programming in C++ in general,) I came across a rohitab tutorial. There are two parts that I have been able to find. Part 1 worked fine, and I'm now working on Part 2, however, I'm getting this error in Code::Blocks:
C:\Users\John\Documents\Windows GUIs\first_gui.cpp||In function 'C:\Users\John\Documents\Windows GUIs\first_gui.o:first_gui.cpp:(.text+0x281)||undefined reference to '_TextOutA#20'|
My code can be found here (broken link).
I would greatly appreciate any help.
Did you link your app against GDI32.LIB?
Looks like a linker error, are you linking to gdi32.lib?
You should download a WINDOWS SDK package, this include all libraries that you will need to create programs with GDI (including gdi32);
Then in codeblocks/compiler/linkersettings choose folder where SDK's lib files are stored.
That's is it!!.