Qt adding library gstreamer-1.0 - c++

I am making a project, dependent on gstreamer-1.0, glib-2.0 and gobject-2.0.
Building in console and in VSCode works fine, but when i get to Qt, i receive the following error message:
:error: cannot find /usr/lib/x86_64-linux-gnu/: File format not recognized
My .pro file:
QT += core
QT -= gui
TARGET = Accord
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
working_directory.cpp \
player_core.cpp \
message.cpp
HEADERS += \
working_directory.h \
message.h \
player_core.h
CONFIG += link_pkgconfig \
c++11
PKGCONFIG += gstreamer-1.0 \
glib-2.0 \
gobject-2.0 \
gio-2.0
INCLUDEPATH += /usr/local/include/ \
/usr/include \
/usr/include/gstreamer-1.0 \
/usr/include/glib-2.0 \
/usr/lib/x86_64-linux-gnu/glib-2.0/include \
/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include
LIBS += /usr/lib/x86_64-linux-gnu/ -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 \
-lgio-2.0 \

With specified pkgconfig should be enough. You don't need to specify the libraries independently. This might be necessary in Windows, but not in Linux. I use the next variables in Linux (Ubuntu):
CONFIG += link_pkgconfig
PKGCONFIG += gstreamer-1.0 glib-2.0 gobject-2.0 gstreamer-app-1.0 gstreamer-pbutils-1.0
If your GStreamer is in the default location it should work.

I solved it by changing QMAKE_CFLAGS_ISYSTEM = -isystem
to QMAKE_CFLAGS_ISYSTEM = -I (can be added to .pro).
for Qt 5.10 +

I think that LIBS += /usr/lib/x86_64-linux-gnu/ is incorrect, hence the
error: cannot find /usr/lib/x86_64-linux-gnu/: File format not recognized.
You probably meant
LIBS += -L/usr/lib/x86_64-linux-gnu/
to add the directory to ld's search path (although that shouldn't be necessary).

Related

How linux and g++ understand what include path it needs to use?

I'm not quite completely understand how linux or g++ (gcc) define what include path it need to use to find some package. Here is what I mean:
I actually have a c++ project in QtCreator and I use qmake build system. I include in my code a header-only framework file, which needs a Boost of one of the last version. I have already in my system boost-1.64.0, but it's too old, so I've installed boost-1.80.0. But when I try to build the program a compilation error raises with the text:
{name_of_my_pro_file}.pro: rpm boost1.64.0-devel is not installed!!!
I thought if I just replace boost folder in /usr/include/ or /usr/local/include/ with folder of the newer boost version linux can use it instead of older one. But the error mentioned above still raises. I've tried to edit boost folder name in Makefile. Directly in my .pro file there is not any mentions about boost. But nothing helped me. I can handle it only when I renamed boost-1.80.0 folder to boost-1.64.0. And now it works.
It seems that name boost-1.64.0 is written somewhere in the system and it doesn't see any other packages.
I guess that I just don't understand how to work with this stuff correctly and doing something wrong. Can somebody explain what should I do?
My distro is Oracle Linux Server 8.4.
EDIT:
My .pro file:
QT += core gui network xml
QMAKE_CXXFLAGS += -std=c++0x
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TilesDataProvider
TEMPLATE = app
#DESTDIR = ./output
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += no_abi_dump
INCLUDEPATH += \
$$PWD \
$$PWD\guts \
$$PWD\SRTM \
$$PWD\tileSources \
/usr/include
CONFIG(release, debug|release){
message(release)
TARGET = TilesDataProvider
OBJECTS_DIR = tmp/TilesDataProvider/release
MOC_DIR = tmp/TilesDataProvider/moc
}
CONFIG(debug, debug|release){
message(debug)
TARGET = TilesDataProvider_d
OBJECTS_DIR = tmp/TilesDataProvider/debug
MOC_DIR = tmp/TilesDataProvider/moc
DEFINES += _DEBUG
}
SOURCES += \
main.cpp \
tileSources/MapTileSource.cpp \
tileSources/SrtmTileSource.cpp \
guts/Position.cpp \
guts/t_task.cpp \
guts/MapConversions.cpp \
SRTM/altdatabank.cpp \
SRTM/altdatamap.cpp \
SRTM/geoid.cpp \
SRTM/srtm_coordinate.cpp \
SRTM/t_geodata.cpp \
SRTM/t_pageid.cpp \
t_image.cpp \
tilesdataprovider.cpp
HEADERS += \
tileSources/MapTileSource.h \
tileSources/SrtmTileSource.h \
guts/MapGraphics_global.h \
guts/Position.h \
guts/t_task.h \
guts/MapConversions.h \
SRTM/altdatabank.h \
SRTM/altdatamap.h \
SRTM/geoid.h \
SRTM/srtm_coordinate.h \
SRTM/t_geodata.h \
SRTM/t_pageid.h \
SRTM/tiff_param.h \
t_image.h \
tilesdataprovider.h

Link Boost with Qt Creator on Mac

I have installed boost using Homebrew and got everything set up in my .pro file.
myProFile
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
src/nmea-tests.cpp \
src/position.cpp \
src/utilities.cpp \
src/parsenmea.cpp
HEADERS += \
headers/parseNMEA.h \
headers/position.h \
headers/types.h \
headers/utilities.h
INCLUDEPATH += headers/
LIBS += -lboost_unit_test_framework
macx {
QMAKE_CFLAGS += -std=c++11 -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++
LIBS += -L"/usr/local/Cellar/boost/1.63.0/lib" -lboost_random
INCLUDEPATH += "/usr/local/Cellar/boost/1.63.0/include"
}
However, when I try to build the project, Qt can't find boost/test/unit_test.hpp file
Compiler Error Message:
/Users/hadyfarhat/Documents/ntu/courses/soft/task4/gps/src/nmea-tests.cpp:3: error: 'boost/test/unit_test.hpp' file not found
#include <boost/test/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~
I would say the better way is using /usr/local/opt/boost for Intel and /opt/homebrew/opt/boost for Apple Silicon in your case. Then you don't need to worry about the problem of the version.
I had to change boost version from 1.63.0 to 1.66.0.
For Future problems with boost use my question as a guide and be sure to install homebrew before that.

Poco PropertyFileConfiguration undefined reference in Qt

currently working on a Qt project and I'd also like to use some aspects of the Poco libraries such as the property file configuration functionality. I got the example in my code from page nine of the documentation here:
http://pocoproject.org/slides/180-Configuration.pdf
The problem is when compiling, a couple of rather oddly formatted undefined reference errors appear.
C:\projects\build-InternetofGauges-Desktop_Qt_5_5_1_MinGW_32bit-Debug\debug\webtunnelhandler.o:-1: In function `ZN16WebTunnelHandler13setConfigFileEv':
C:\projects\InternetofGauges\webtunnelhandler.cpp:41: error: undefined reference to `_imp___ZN4Poco4Util25PropertyFileConfigurationC1ERKSs'
C:\projects\InternetofGauges\webtunnelhandler.cpp:43: error: undefined reference to `_imp___ZNK4Poco4Util21AbstractConfiguration6getIntERKSs'
C:\projects\build-InternetofGauges-Desktop_Qt_5_5_1_MinGW_32bit-Debug\debug\webtunnelhandler.o:-1: In function `ZN4Poco7AutoPtrINS_4Util25PropertyFileConfigurationEEptEv':
C:\My-Devices-SDK\include\Poco\AutoPtr.h:190: error: undefined reference to `_imp___ZN4Poco20NullPointerExceptionC1Ei'
C:\My-Devices-SDK\include\Poco\AutoPtr.h:190: error: undefined reference to `_imp___ZN4Poco20NullPointerExceptionD1Ev'
collect2.exe:-1: error: error: ld returned 1 exit status
My .pro file
QT += core
QT += network
QT += sql
QT += xml
QT -= gui
CONFIG += c++11
TARGET = InternetofGauges
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += "C:\\My-Devices-SDK\\include" \
"C:\\OpenSSL\\MinGW\\include"
LIBS += -L"C:\\My-Devices-SDK\\lib\\" \
-lPocoUtild \
-lPocoNetd \
-lPocoNetSSLd \
-lPocoFoundationd \
-lPocoJSONd \
-lPocoWebTunneld \
-lPocoXMLd
LIBS += -L"C:\\My-Devices-SDK\\lib\\" \
-lPocoUtil \
-lPocoNet \
-lPocoNetSSL \
-lPocoFoundation \
-lPocoJSON \
-lPocoWebTunnel \
-lPocoXML
LIBS += -L"C:/OpenSSL/MinGW/lib/"
SOURCES += main.cpp \
webclient.cpp \
startuphandler.cpp \
webtunnelhandler.cpp
DISTFILES += \
Todo.readme
HEADERS += \
webclient.h \
startuphandler.h \
webtunnelhandler.h
The problem code in question
#include <Poco/Util/PropertyFileConfiguration.h>
#include <Poco/AutoPtr.h>
#include "webtunnelhandler.h"
using Poco::AutoPtr;
using Poco::Util::PropertyFileConfiguration;
/* ... */
void WebTunnelHandler::setConfigFile()
{
AutoPtr<PropertyFileConfiguration> pConf;
pConf = new PropertyFileConfiguration("WebTunnelAgent.properties");//Error appears here
int key1 = pConf->getInt("webtunnel.httpPort");//and also here
return;
}
Now, I've compiled all the poco libraries with MinGW and Qt is also configured for MinGW and compiles and runs great with other parts of my program. I'm also happily using Qt 5.5.1 with the 3.1.6 Qt Creator. My happiness with Qt unfortunately doesn't help my issues.
I have looked at many a stack overflow question on similar topics, and have attempted to recompile the libraries as well as explicitely include the libraries in the .pro file. I also peeked into the Auto.h file and found that it ends up calling the null pointer exception likely due to the line pConf = new PropertyFileConfiguration("WebTunnelAgent.properties"); getting angry at me.
What are the causes of this error? And how does one fix this error?
Linking order of libraries matters and that has nothing to do with Poco:
the linker searches and processes libraries and object files in the
order they are specified. Thus, 'foo.o -lz bar.o' searches library
'z' after file foo.o but before bar.o. If bar.o refers to functions
in 'z', those functions may not be loaded.
Okay so I did manage to fix it. I realized that the order of libraries does in fact matter as there are some dependencies between libraries in this case. I also had to add another windows specific library to make it work. Here's the section of the .pro file that worked
LIBS += -L"C:\\My-Devices-SDK\\lib\\" \
-lPocoUtild \
-lPocoNetd \
-lPocoNetSSLd \
-lPocoXMLd \
-lPocoJSONd \
-lPocoWebTunneld \
-lPocoFoundationd
LIBS += -L"C:\\My-Devices-SDK\\lib\\" \
-lPocoUtil \
-lPocoNet \
-lPocoNetSSL \
-lPocoXML \
-lPocoJSON \
-lPocoWebTunnel \
-lPocoFoundation
LIBS += -L"C:/OpenSSL/MinGW/lib/"
win32:LIBS += -lIphlpapi
As I said above, Iphlpapi is needed as well as that poco order. Hope this helps someone eventually!

LNK1146: no argument specified with option '/LIBPATH:' error in Qt

I imported my Qt application developed on linux to windows. Now when I build my project I am getting this error:
error: LNK1146: no argument specified with option '/LIBPATH:'
I created a new project on windows and it works perfectly fine. One of the possible reason that would cause this is having spaces in the project path,but there are no spaces in my project path.Could you let me know how I could resolve this issue.
This is my .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2014-12-08T09:19:31
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FirstProject
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
SOURCES += main.cpp\
firstscreen.cpp \
secondscreen.cpp \
thirdscreen.cpp
INCLUDEPATH += C:\Users\user_name\tango\ \
C:\Users\user_name\omniORB4\ \
C:\Users\user_name\omnithread.h
HEADERS += firstscreen.h \
C:\Users\user_name\tango\ \
C:\Users\user_name\omniORB4\ \
C:\Users\user_name\omnithread.h \
secondscreen.h \
thirdscreen.h
LIBS += -L -lomnithread \
-L -lomniORB4 \
-L -ltango
FORMS += firstscreen.ui \
secondscreen.ui \
thirdscreen.ui
The problem happens because the flag -L was specified, but no library paths were given:
LIBS += -L -lomnithread \
-L -lomniORB4 \
-L -ltango
To fix this problem, you must provide the paths where the .lib files are located, which would be something like:
LIBS += -L"C:\\Users\\user_name\\omnithread\\lib" -lomnithread \
-L"C:\\Users\\user_name\\omniORB4\\lib" -lomniORB4 \
-L"C:\\Users\\user_name\\tango\\lib" -ltango
Remember: there must be no empty spaces between -L and the path string.
So doing it like this will also throw the same error:
LIBS += -L "C:\\Users\\user_name\\omnithread\\lib" -lomnithread \
-L "C:\\Users\\user_name\\omniORB4\\lib" -lomniORB4 \
-L "C:\\Users\\user_name\\tango\\lib" -ltango
In your .pro file the problem is probably the empty "-L" when assigning to LIBS. You need to write there the path for the following library specified "-l".
I fixed a less obvious situation like this:
Since the problem was hidden in the response file used by JOM I started JOM manually as executed by qmake. Simply copy the JOM call and execute it with an additional -U parameter to see the content of the response file:
C:\Qt\Tools\QtCreator\bin\jom.exe -U -f Makefile.Debug > x.txt
(of course you have to call it in the directory mentioned in the qmake output)
Next I checked all /LIBPATH: occurrences in x.txt. So it was easy to find the culprit and fix the .pro file.
In the current .pro file you specified library names, but didn't specify paths for your external libs. Those '-l' and '-L' keys are used exactly for this.
Some advice:
Use relative paths
Use some variables in .pro file, like DESTDIR and reference them in lib path argument, like -L"$$DESTDIR"

Compiling SDL2 in QtCreator (MinGW)

Run into a recent issue whilst trying to compile SDL2 with QtCreator using MinGW. It seems that for some reason the libraries are not linking.
I know 100% that the libraries are in the correct place, as you can see in this picture:
And how i'm linking in my .pro file:
##Windows
win32 {
TEMPLATE = app
CONFIG -= app_bundle
CONFIG -= qt
##Debug & Release Mode Configs
CONFIG(debug, debug|release) {
CONFIG += console
} else {
CONFIG -= console
}
INCLUDEPATH += "C:\Users\Daniel\Desktop\SDL2-devel-2.0.0-mingw\SDL2-2.0.0\x86_64-w64-mingw32\include\SDL2"
LIBS += -L"C:\Users\Daniel\Desktop\SDL2-devel-2.0.0-mingw\SDL2-2.0.0\x86_64-w64-mingw32\lib" \
-lmingw32 \
-lSDL2 \
-lSDL2main \
-lSDL2_ttf \
-lSDL2_image \
-lSDL2_mixer \
-lopengl32
}
Edit:
Well I was building with the wrong version of the libs! Doh! But a new problem arises, which i think has something to-do with SDLmain.. Must be missing something in my .pro file but totally unsure what :S
Well solved it. Link for any future reference;
http://www.cplusplus.com/forum/beginner/110753/
-lSDL2main needs to be before -lSDL2. Dammit.