FFmpeg development on Eclipse on Windows - c++

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?

Related

I have an image file inside my Eclipse CDT project. How do I reference it in my code, so collaborators can use it when they run the code?

I'm currently working with a very small team on a project in C++ that involves displaying an image. We wish to be able to collaborate on it by sharing the code in a remote Git repository, and to this end, we have all agreed to switch to using Eclipse CDT instead of Xcode/Visual Studio/whatever else. Ideally, we should be able to clone the repository onto any machine with Eclipse CDT (and the relevant libraries) installed and build then successfully run the code there without any changes to it, but the current working version of the code uses the path of an image from my user directory. I have a copy of that image inside the project, and my question is, how can I use that so my teammates can use it too?
I've tried to use a relative path (which I've heard would find it relative to where the executable is run from rather than where it is anyhow), and I've tried substituting PROJECT_PATH for various prefixes of the full absolute path, but neither has worked. I'm also aware that the path of the image could be passed as a command-line argument, but I would prefer to have it inside the project, and although it could be appropriate in this situation I can think of many more in which it would not be (loading a sprite for a game, for example), and it just bothers me to not know how to do something that ought to be so basic.
A good bit of searching Stack Overflow has come up with many solutions to similar problems, but what little I've found for C++ has been for Visual Studio or Code::Blocks, and what little I've found for Eclipse has been for Java. It all seems to involve either "resource loaders" or directly shoving the relevant data into the binary, but I haven't been able to find documentation for these "resource loaders" and integrating the data into the executable using a hex editor seems like a lot of extra work to do each time the project gets built (plus I haven't a clue how to make it work with the library functionality I'm using).
The version of Eclipse IDE for C/C++ Developers that I'm using is 2018-12 (4.10.0), on macOS Mojave 10.4.2, and the single teammate I've interacted with so far is on some-or-another version of Ubuntu running presumably the same version of Eclipse. We should both be able to build and run the project, using the image, from the same files cloned from the same Git repository. The project is a "C++ Managed Build", because I couldn't figure out how to get the "CMake Project" to work (plus I don't know how to use CMake either way), with the "MacOSX GCC" toolchain (which come to think of it is probably another issue with moving the code between systems, but that's a problem for another day) because I have no idea how to use the "Cross GCC" toolchain.
This problem seems general enough that it shouldn't much matter, but the exact line of code that needs the path to the image currently looks like
cv::Mat image = cv::imread("/my/user/directory/Documents/8by8m.png");
using OpenCV 3.4.3, and with my attempts to use the copy of the image in the project directory the Mat has been coming up empty.

Why does Eclipse's indexer recognize some classes, but not others?

I setup Eclipse C++ - Version: Neon Release (4.6.0) - Build id: 20160613-1800 - with the GNU gcc ARM Embedded Toolchain (not gcc4mbed). The toolchain works great, but I ran into an issue involving (I think) Eclipse's indexer on my latest project.
My problem should be clear if I give the steps to reproduce my issue:
Create some class and #include "mbed.h"
Declare some member variable of type DigitalOut. Notice that Eclipse recognizes this just fine because the text turns bold, and code completion works fine when interacting with the variable.
Declare another member variable of type PwmOut. Notice that Eclipse does NOT recognize this, the text does not turn bold, and code completion doesn't work because Eclipse doesn't know what a PwmOut is. Eclipse says:
Errors (1 item)
Type 'PwmOut' could not be resolved. - main.cpp - Semantic Error
Build project completes successfully, compiler throws no errors, even though Eclipse still does not recognize PwmOut. Binary runs correctly on my LPC1768.
How is it possible that Eclipse can recognize DigitalOut but not PwmOut? Both are listed in the same code block inside mbed.h--and DigitalOut.h is in the same directory as PwmOut.h.
If it helps, here is an example project I exported from developer.mbed.org that you can import into Eclipse C++ as an existing Makefile project.
I have tried adapting suggestions I found such as adding the directory with these headers in Project->Properties->C/C++ General->Paths and Symbols->Includes, rebuilding the index, and "Freshening" all files in the index. I just can't get Eclipse to recognize them.
EDIT: I'd like to add that if I click on the "Type 'PwmOut' could not be resolved" error message in the "Problems" window, Eclipse locks up for a few seconds, then crashes with a stack overflow.
I am sorry to say that my solution probably isn't very generalizable or helpful to other people's Eclipse C++ issues.
Solution:
In your developer.mbed.org exported project folder, find the file "device.h" located in the mbed subdirectory at
./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/device.h
Mine was more or less empty.
Replace this device.h with the one located at the mbed official repo for the LPC1768.
Notice this device.h has a bit more detail in it.
Rebuild Eclipse's index. Eclipse should now be happy.
My interpretation of why this fixes Eclipse's problem:
When you export a project from developer.mbed.org, it gives you a zip with all your sources, as well as an "./mbed" directory that contains the header files and objects for the specific microcontroller with which you're working.
Most of NXP/ARM's controllers should have some variation of a DigitalOut or DigitalIn class, since that kind of functionality is very basic and common to a controller. However, this particular chip (the LPC1768) has an independent module onboard to handle pulse width modulation. This module might not be found on all of NXP/ARM's chips, so you can think of this as a special case we need to take care of when setting up a workspace environment in an IDE such as Eclipse.
Particularly, the mbed exported project contains a header located (for me) at
./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/device.h
This device header should define preprocessor directives specific to the device you're programming. Mine was empty, but the one at the official repo for the LPC1768 has a lot of #defines in it for this controller. As long as the DEVICE_PWMOUT directive in device.h is defined to be equal to 1 (and it is), Eclipse will know that it is supposed to recognize the PwmOut class.

Browsing MariaDB's source code with CLion

I'm attempting to explore MariaDB's source code and thought that the easiest way would be to use a C++ IDE. I used the Bash script debian/autobake-deb.sh bundled in MariaDB to compile the project, then opened it with CLion. Unfortunately it looks like a lot of code is not recognized (even though CMake is bundled with CLion) which prevents me from using autocomplete, function references and such in a lot of places.
For instance when I open libmysqld.c :
There are errors almost every line.
I'm a beginner in C/C++ so I'm not sure what I would have to configure or install to make CLion recognize the symbols better.
edit : Updated screenshot with status bar

Can't configure OpenCV with Qt properly?

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.

ArUco program from scratch

I'm using the ArUco library with OpenCV (more information here) but I can't find a way to build and run a program from scratch.
Once I installed the library I have access to different examples but if I want for instance to create a new file and add the library headers inside it, how can I compile and run it ? (with a command line or IDE, anything is fine)
Thank you
I sent and email to the library's author and he added clear instructions at the end of the project webpage :)
It seems you need to learn how to use your IDE's, compilation tools and general compilation basic stuff. This is not a question related to Aruco, or mostly any other tags you have set.
Try to lean CMake first, 'cause Aruco compilation is based on CMake: http://www.cmake.org/
You can start by just editing the aruco_simple example.
For a IDE that works right away with CMake you can try either Qt Creator >3.1 or KDevelop. Both free.