How do I get the compiler to read a downloaded library? - c++

I've downloaded OpenMesh for Linux Ubuntu. I successfuly compiled it following instructions at
https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-8.0-Documentation/a04067.html
using cmake, then make. The result is a "build" folder containing, among other things, a makefile and .o files. I want to use OpenMesh in QT Creator, so I put an example code found on their website at
https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-8.0-Documentation/a04088.html
basically it just displays a cube using cout and data structures I've downloaded. However, there are compilation errors of type "undefined reference to" everywhere.
Here is an example : "../OpenMesh-8.1/src/OpenMesh/Core/Mesh/ArrayKernel.hh:154: error : undefined reference to `OpenMesh::ArrayKernel::is_valid_handle(OpenMesh::HalfedgeHandle) const'
I think that this could be caused because I didn't tell the compiler somehow where I compiled OpenMesh, because someone else got this error at https://linuxfr.org/forums/programmation-c/posts/openmesh
I don't really get it, though, and I don't know much about the compiling process. I don't know how to import downloaded libraries and run them in QT. Does anyone know a simple way to do this ?
Any help would be really appreciated.

The correct way to do it is to open CmakeLists.txt in qt creator, which organizes everything correctly.

Related

SFML Project Running Perfectly in Codeblocks but Release EXE Giving Errors Even with all DLLs included

So I have this issue and I cannot seem to find a solution to it online. I am dynamically linking SFML following this tutorial using the same exact versions of both Codeblocks and SFML. It works perfectly fine in the IDE but when I try to run the EXE file from the release folder (Yes, I do have all my SFML DLLs in the same folder) it gives 3 errors along the lines of:
_ZSt4_throw_out_of_range_fmtPKcz could not be located in sfml-graphics-2.dll
I also tried linking it statically according to this guide, however this is worse since it doesn't even compile. It gives errors along the lines of:
undefined reference to 'FT_Set_Pixel_Sizes'
Honestly I am lost and out of ideas at this point. Any ideas on what I could be doing wrong?

Trying to compile Qt/C++ code in Code Blocks

I am new with QT, so I am not sure how this works. Im trying to compile some C++ code that includes QT code for graphics. I am using the GNU compiler in Code blocks, but whenever I compile it, It gives this error:
fatal error: QGraphicsRectItem: No such file or directory
So how do I fix this? Is there a different compiler I need?
My include statement is:
#include <QGraphicsRectItem>
It is hard to tell from the info you provided. There are several problems that yield this error, not configured the files correctly, there is no such header file, ..., etc. The error is clear though.
Qt is a big library that is why we need qmake to take care of configuring the files, so theoretically speaking, you can generate Makefile and copy-paste the related data to your code-blocks project. As far as I know, qmake supports Visual Studio and Xcode projects but not sure if there is a tool for code-blocks.

Class QSqlError has no member nativeErrorCode()

I have been struggling with this problem for quite a while, and unfortunately neither my own reasoning, nor google search helped me. In simple terms, I am trying to use nativeErrorCode() function with QSqlError class. Compiler says: mainwindow.cpp:43:86: error: ‘class QSqlError’ has no member named ‘nativeErrorCode’. This is the line that it references (to be exact, two lines):
errorCreatingBooksTableMessageBox.setDetailedText((query.lastError().nativeErrorCode().isEmpty()) ?
query.lastError().text() : query.lastError().nativeErrorCode() + "\n" + query.lastError().text());
Problem seems trivial, but I can't find an answer on my own. #include is in mainwindow.h file. After some research, I noticed other people on other forums suggesting that compiler uses wrong version of the header file, which would seem very likely to happen since function nativeErrorCode() was introduced in Qt5. I tried to move qt4 folder to trash, but still, no effect. Any help would be appriciated
I am not sure which OS you encounter this issue. However In most of the Linux OS Image, prebuild with Qt4, Even we build Qt5 libraries additionally, the system environment may use old Qt4 libraries to generate make files. This is very common if we are building Qt5 from source codes. So it would be better you can try to execute qmake from Qt5 path. So the Makefile will be created to build for Qt5 libraries.
In order to confirm, Open the Makefile and check the variable QMAKE is refering to Qt5 or Qt4 libraries.
I am updating this from my system for your reference, "QMAKE = /home/user1/Qt5.6.0/5.6/gcc_64/bin/qmake" From this, It is clear that Makefile is using Qt5 libraries and further compilation, Qt5 libraries will be used to compile my application source code.

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?

Using Qt5 in a library

I have a library that integrates some GTK functionnalities, and I decided to switch to Qt.
So I created a test cmake file to try to integrate Qt5 but it does not work because when I load the libary dynamically using an executable I get "undefined symbols".
undefined symbol: _ZN8UIWindow16staticMetaObjectE
I googled a lot, and it does not seems to be that simple si any kind of help, or comments would be much appreciated.
Here are the relevant files I use.
Ok I found the solution. Since I use different folders for the header and the source files, I have to manually specify where is the file containing the qt code.
QT5_WRAP_CPP( MOCS_HDRS ${INCLUDE_DIR}/UIWindow.h )
The error indicates that the MOC file for your UIWindow class was not generated or built correctly. Qt expects certain meta-information for the class generated by MOC (MetaObject Compiler, IIRC).
Your CMake script turns on automoc which usually works, so I suggest you take a look at the output of CMake to see if it is running that step for your class or not.