I am programming for Ubutu linux, and am tryi9ng to display video. However, i have run into a problem:
i am not able to create instances of QVideoSurfaceFormat, due to the following error:
undefined reference to `QVideoSurfaceFormat::QVideoSurfaceFormat(QSize const&, QVideoFrame::AVPixelFormat, QAbstractVideoBuffer::HandleType)'
collect2: error: ld returned 1 exit status
I am guessing that the problem lies inQt Multimedia binaries, somewhere. But in the compile output there is the following:
g++ -o LPR_Demo main.o mainwindow.o imgProcessor.o qpicturelabel.o aboutdialog.o state.o videowidget.o videowidgetsurface.o videoplayer.o qt_videoreader.o roidialog.o recognitionresult.o ffmpeg_reader.o moc_mainwindow.o moc_imgProcessor.o moc_aboutdialog.o moc_videowidget.o moc_videowidgetsurface.o moc_videoplayer.o moc_qt_videoreader.o moc_roidialog.o moc_recognitionresult.o qrc_lpr_Res.o -L/usr/lib/i386-linux-gnu -L/usr/X11R6/lib -L/home/truskov/development/lprsdk/LPR/bin -lLPR -lavformat -lavcodec -lavutil -lswscale -L/usr/lib/i386-linux-gnu -lQtMultimediaKit -lQtOpenGL -lQtGui -lQtNetwork -lQtCore -lGL -lpthread
where QtMultimediaKit library seems to be in place.
My .pro file goes like this:
QT += core gui
win32:QT+= multimedia
unix {
QT+= mobility multimediakit
MOBILITY = multimedia
CONFIG += mobility
}
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = LPR_Demo
TEMPLATE = app
however, when qmake runs, i get following messages:
Project MESSAGE: Warning: unknown QT: mobility
Project MESSAGE: Warning: unknown QT: multimediakit
What could cause this? How can it be solved?
Related
I have some c++ code (Snowboy demo - demo.cc) and successfully build it on my RaspPI Zero using g++:
g++ -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -I../../ -std=c++0x -Wall -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -rdynamic -DHAVE_POSIX_MEMALIGN -Iportaudio/install/include -O3 demo.cc portaudio/install/lib/libportaudio.a ../..//lib/rpi/libsnowboy-detect.a -ldl -lm -Wl,-Bstatic -Wl,-Bdynamic -lrt -lpthread portaudio/install/lib/libportaudio.a -L/usr/lib/atlas-base -lf77blas -lcblas -llapack_atlas -latlas -lasound -o demo
To debug it I try to use QtCreator and create Qt project file:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
HEADERS += demo.h
SOURCES += \
demo.cc
INCLUDEPATH += ../../
INCLUDEPATH += portaudio/install/include
LIBS += -Lportaudio/install/lib \
-lportaudio \
-L../../lib/rpi -lsnowboy-detect \
-L/usr/lib/atlas-base \
-ldl -lm -lrt -lpthread \
-lf77blas -lcblas -llapack_atlas -latlas -lasound
But with this configuration in QtCreator I receive build errors:
/home/pi/Prj/snowboy/examples/C++/demo.cc:213: error: undefined reference to `snowboy::SnowboyDetect::SnowboyDetect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Did I forget to specify any parameters that was used with g++ in Qt project file?
Is it possible you advise me a simple way to debug c++ code with external dependencies in Raspb Pi zero?
Snowboy for some ungodly reason requires you to use -D_GLIBCXX_USE_CXX11_ABI=0 (google it). You have this flag in your command line, which is correct in the context of Snowboy, but are missing it in your .pro file. Add it.
QMAKE_CPPFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
or something like that.
You can also try downgrading your language standard option to C++98 (not recommended but should work if your demo is not using any c++11-specific code).
I personally think that any software that is still using -D_GLIBCXX_USE_CXX11_ABI=0 in 2019 needs to be scrapped or forked, but whatever floats your boat.
This question help me run the Snowboy demo on qt-creator successfully.
I will give the question a fuller answer, to help more people: You just add the code to .pro file:
QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
LIBS+= /home/zhurui/QtProject/Test/lib/libsnowboy-detect.a \
-ldl -lm -lrt -lpthread \
/home/zhurui/QtProject/Test/portaudio/install/lib/libportaudio.a \
-L/usr/lib/atlas-base \
-lf77blas -lcblas -llapack_atlas \
-latlas -lasound
In my Qt program I have to convert a string to a hash. I want to use OpenSSL on Debian. Little brief of my code:
#include <openssl/sha.h>
...
unsigned char data[] = "data to hash";
unsigned char hash[SHA512_DIGEST_LENGTH];
SHA512(data, sizeof(data) - 1, hash);
I have installed openssl and libssl-dev. And I also have changed my .pro document, looks like that:
TEMPLATE = app
QT = core gui
HEADERS += window.h
PKGCONFIG += openssl //found in another solution, but it does not work
LIBS += -L/usr/share/doc libssl-dev
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp window.cpp
In LIBS I have tried all possible locations that I get with sudo dpkg -L libssl-dev . Does anyone what I am missing? It doesn't compile and I sure is about that.
Thanks.
Here is the error when linking:
/usr/lib/x86_64-linux-gnu/qt4/bin/qmake -o Makefile App.pro
g++ -m64 -Wl,-O1 -o App main.o window.o moc_window.o -L/usr/lib/x86_64-linux-gnu -L/usr/share/doc/libssl-dev -libssl-dev -lQtGui -lQtCore -lpthread
/usr/bin/ld: cannot find -libssl-dev
collect2: error: ld returned 1 exit status
Makefile:105: recipe for target 'App' failed
make: *** [App] Error 1
In general if the library is libsomelib.so you must import it using -lsomelib, and in your case assuming that you have installed it using the system's tools it is not necessary to pass it a path, just add the following since the library is libssl.so:
LIBS += -lssl -lcrypto
or you can also use pkg-config:
PKGCONFIG += libssl
where /usr/lib/pkgconfig/libssl.pc is:
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenSSL-libssl
Description: Secure Sockets Layer and cryptography libraries
Version: 1.1.0g
Requires.private: libcrypto
Libs: -L${libdir} -lssl
Libs.private: -ldl
Cflags: -I${includedir}
I installed BOOST 1.57 to allow me to use some new features, so I simply created a directory at /usr/local/boost which contains the root BOOST folders.
I have managed to create the example code shown here and compile it using:
g++ example.cpp -o example -lrt
Here is my .pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Ph2_ACF
TEMPLATE = app
CONFIG += c++11 debug
QMAKE_CXXFLAGS += -g -O1 -w -pedantic -fPIC -std=c++11 -lrt `root-config --cflags --evelibs` -Wcpp
LIBS += -L../lib -lPh2_Interface -lPh2_Description -lPh2_System -lPh2_Tools -lPh2_Utils
LIBS += $(LibraryPaths:%=-L%) -uhal `root-config --glibs`
LIBS += -L/usr/lib/ -lqjson
INCLUDEPATH += /usr/include/qjson/
INCLUDEPATH += $(ROOTSYS)/include
INCLUDEPATH += /../../Ph2DAQ_dev/
INCLUDEPATH += /usr/local/boost
LIBS += -L/usr/local/boost/libs
And here is my error:
g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.8.5/lib -o Ph2_ACF main.o mainview.o startup.o setuptab.o setuptabviewmanager.o settings.o systemcontroller.o cbcregisterstab.o cbcregviewmanager.o provider.o aboutbox.o systemcontrollerworker.o cbcregisters.o mainviewmanager.o cbcregisterworker.o tbrowsertab.o calibrate.o hybridtest.o hybridtestworker.o hybridtestviewmanager.o hybridtesttab.o moc_mainview.o moc_startup.o moc_setuptab.o moc_setuptabviewmanager.o moc_settings.o moc_systemcontroller.o moc_cbcregisterstab.o moc_cbcregviewmanager.o moc_aboutbox.o moc_systemcontrollerworker.o moc_cbcregisters.o moc_mainviewmanager.o moc_cbcregisterworker.o moc_tbrowsertab.o moc_calibrate.o moc_hybridtest.o moc_hybridtestworker.o moc_hybridtestviewmanager.o moc_hybridtesttab.o qrc_Resources.o -L/usr/local/Trolltech/Qt-4.8.5/lib -L/usr/include/boost -lboost_system -lboost_thread -lboost_regex -L../lib -lPh2_Interface -lPh2_Description -lPh2_System -lPh2_Tools -lPh2_Utils -L/opt/cactus/lib -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal -uhal `root-config --glibs` -L/usr/lib/ -lqjson -L/usr/local/boost/libs -lQtGui -L/usr/local/Trolltech/Qt-4.8.5/lib -L/usr/X11R6/lib -lQtCore -lpthread
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libdl.so when searching for -ldl
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libdl.a when searching for -ldl
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libpthread.so when searching for -lpthread
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libpthread.a when searching for -lpthread
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libm.so when searching for -lm
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libm.a when searching for -lm
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libpthread.so when searching for -lpthread
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libpthread.a when searching for -lpthread
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libc.so when searching for -lc
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /usr/lib//libc.a when searching for -lc
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: hybridtestworker.o: undefined reference to symbol 'shm_open##GLIBC_2.2.5'
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: note: 'shm_open##GLIBC_2.2.5' is defined in DSO /lib64/librt.so.1 so try adding it to the linker command line
/lib64/librt.so.1: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [Ph2_ACF] Error 1
Just to note all the previous skipping warnings were fine before, it's just this final 'shm_open##GLIBC_2.2.5' which seems to break it.
All I've added is:
#include <boost/interprocess/shared_memory_object.hpp>
// SNIP !
using namespace boost::interprocess;
// SNIP !
shared_memory_object shm_obj
(
create_only //only create
,"shared_memory" //name
,read_write //read-write mode
);
Into one of my files.
Any idea what is going on?
EDIT:
Adding:
LIBS += -L/usr/local/boost/libs -lrt
Gives me the new error:
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: mainview.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: note: '_ZN5boost6system15system_categoryEv' is defined in DSO /opt/cactus/lib/libboost_system.so.1.48.0 so try adding it to the linker command line
/opt/cactus/lib/libboost_system.so.1.48.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [Ph2_ACF] Error 1
It looks like you added -lrt to the compile flags, and they're not being included at the link stage.
Try adding -lrt -lboost_system to the LIBS variable (like -lPh2_Description and the rest)
I want to link boost in my pro file and found following answer:
Boost with Qt Creator and Linux
I build a minimal example:
My pro File
QT += core
QT -= gui
TARGET = threadtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH +=/path/boost/
LIBS += -L/path/boost/lib/ -lboost_thread -lboost_system
SOURCES += main.cpp
My main:
#include <QtCore/QCoreApplication>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
void woker(){
boost::posix_time::seconds t(10);
std::cout <<" working" << std::endl;
boost::this_thread::sleep(t);
}
int main(int argc, char *argv[])
{
std::cout <<" r" << std::endl;
QCoreApplication a(argc, argv);
boost::thread w(woker);
w.join();
std::cout <<" d" << std::endl;
return a.exec();
}
I get the undefined reference to boost error. I don't understand this...
In Windows I only did:
LIBS += "-LC:/boost_1_55_0/lib32-msvc-10.0/"
However, this is also not working in Linux.
Does anyone have any ideas?
Edit
14:41:04: Führe Build-Schritte für Projekt threadtest aus...
14:41:04: Starte "/usr/bin/qmake-qt4" /home/user/threadtest/threadtest.pro -r -spec linux-g++
14:41:04: Der Prozess "/usr/bin/qmake-qt4" wurde normal beendet.
14:41:04: Starte "/usr/bin/make" -w
make: Entering directory `/home/user/threadtest-build-desktop-Qt_4_8_1_in_Pfad__System__Release'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../threadtest -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I../boost -I. -I../threadtest -I. -o main.o ../threadtest/main.cpp
g++ -Wl,-O1 -o threadtest main.o -L/usr/lib/x86_64-linux-gnu -L/home/user/boost/lib/ -lQtCore -lpthread
main.o: In function `woker()':
make: Leaving directory `/home/user/threadtest-build-desktop-Qt_4_8_1_in_Pfad__System__Release'
main.cpp:(.text+0x2aa): undefined reference to `boost::this_thread::sleep(boost::posix_time::ptime const&)'
main.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
main.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED2Ev[_ZN5boost6detail11thread_dataIPFvvEED5Ev]+0x8): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
main.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
main.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED0Ev[_ZN5boost6detail11thread_dataIPFvvEED5Ev]+0xc): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
main.o: In function `boost::detail::thread_data<void (*)()>* boost::detail::heap_new_impl<boost::detail::thread_data<void (*)()>, void (*&)()>(void (*&)())':
main.cpp:(.text._ZN5boost6detail13heap_new_implINS0_11thread_dataIPFvvEEERS4_EEPT_T0_[boost::detail::thread_data<void (*)()>* boost::detail::heap_new_impl<boost::detail::thread_data<void (*)()>, void (*&)()>(void (*&)())]+0x52): undefined reference to `vtable for boost::detail::thread_data_base'
main.o: In function `main':
main.cpp:(.text.startup+0x60): undefined reference to `boost::thread::start_thread()'
main.cpp:(.text.startup+0x6a): undefined reference to `boost::thread::join()'
main.cpp:(.text.startup+0x92): undefined reference to `boost::thread::~thread()'
main.cpp:(.text.startup+0xc6): undefined reference to `boost::thread::~thread()'
main.o:(.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[typeinfo for boost::detail::thread_data<void (*)()>]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: ld returned 1 exit status
make: *** [threadtest] Error 1
14:41:06: Der Prozess "/usr/bin/make" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen des Projekts threadtest(Ziel: Desktop)
Bei der Ausführung von Build-Schritt 'Make'
EDIT 2:
cmake_minimum_required(VERSION 2.8)
project(app_project)
set(Boost_NO_SYSTEM_PATHS ON)
set(BOOST_ROOT path/boost)
find_package(Boost 1.55 REQUIRED COMPONENTS thread filesystem)
if(BOOST_FOUND)
message("boost found")
endif()
add_executable(test main.cpp)
if(TARGET test)
target_link_libraries(test
-lboost_thread
-lboost_system
)
endif()
I wrote a small example with cmake. This is running well, however on cmake i have the command ignore boost system path. You know something similar to qt ?
For VS2008, Boost 1_55, Qt4 4.8.6, I was able to get your code to compile with the following qmake file.
QT += core
QT -= gui
TARGET = threadtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
win32{
INCLUDEPATH += d:/gnu/vs2008/x64/include
LIBS += -Ld:/gnu/vs2008/x64/lib
LIBS += -lboost_thread-vc90-mt-1_55
LIBS += -lboost_system-vc90-mt-1_55
}
unix{
LIBS += -L/usr/lib64
LIBS += -L/usr/local -L/usr -lboost_thread-mt -lboost_system-mt
}
SOURCES += main.cpp
With the same qmake pro file, i was also able to get your code to compile on RHEL6 with Qt4 4.8.6 and the stock Boost
When I tried using only INCLUDEPATH += /path/to/boost/directory/ worked on both Windows and Linux. No need to use LIBS += .... .
I'm updating a code from Qt3 to Qt4. I used qt3to4 porting tool, and it fixed some of my issues. But a few errors are remaining:
g++ -m64 -Wl,-O1 -o CONVECTION_DYN_CODE_version_initiale Convection_points.o Convection_points_prof.o glbox.o globjwin.o main.o algebra.o evector.o matrix.o matrix4.o quaternion.o write_binary.o write_binary_normals.o moc_glbox.o moc_globjwin.o -L/usr/lib/x86_64-linux-gnu -L/usr/X11R6/lib64 -lQtOpenGL -lQtGui -lQtCore -lGLU -lglut -lGL -lpthread -lCGAL -fp-model -lboost_thread -lgmp
glbox.o:(.rodata._ZTI7Q3GList[typeinfo for Q3GList]+0x10): undefined reference to `typeinfo for Q3PtrCollection'
&
glbox.o:(.rodata._ZTV7Q3GList[vtable for Q3GList]+0x18): undefined reference to `Q3GList::clear()'
glbox.o:(.rodata._ZTV7Q3GList[vtable for Q3GList]+0x20): undefined reference to `Q3GList::~Q3GList()'
glbox.o:(.rodata._ZTV7Q3GList[vtable for Q3GList]+0x28): undefined reference to `Q3GList::~Q3GList()'
glbox.o:(.rodata._ZTV7Q3GList[vtable for Q3GList]+0x30): undefined reference to `Q3PtrCollection::newItem(void*)'
...
Both Q3GList and Q3PtrCollection are internal classes. I added the corresponding headers but I still got these errors. I don't know how to fix it since it seems to be internal issues.
Any ideas?
You should also link against qt3support module.
Add
QT += qt3support
to your project settings.