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 += .... .
Related
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 was using the OpenCV library to make a console application in Qt Creator (I'm just using QMake and the IDE, not any of the Qt libraries). This is on Ubuntu.
First I was using OpenCV dynamically (using an .so) But I want to execute my application on PCs that don't have OpenCV installed. So I'm trying to make a standalone executable:
I recompile and install OpenCV statically (by using the parameter -DBUILD_SHARED_LIBS=OFF )
I tried adding CONFIG += staticlib on my project.pro but I had remarked that it's still using the dynamic library
I tried to compile on profile/debug/release but none of these build options give me the good result
I finally tried to add QMAKE_LFLAGS += -static and recopied the line on opencv.pc:
LIBS += -L/usr/local/lib -lopencv_contrib -lopencv_stitching -lopencv_nonfree -lopencv_superres -lopencv_ocl -lopencv_ts -lopencv_videostab -lopencv_gpu -lopencv_photo -lopencv_objdetect -lopencv_legacy -lopencv_video -lopencv_ml -lopencv_calib3d -lopencv_features2d -lopencv_highgui -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf -ljasper -ltiff -lpng -ljpeg -lopencv_imgproc -lopencv_flann -lopencv_core -lzlib -lswscale-ffmpeg -lavutil-ffmpeg -lavformat-ffmpeg -lavcodec-ffmpeg -lgthread-2.0 -lfreetype -lfontconfig -lglib-2.0 -lgobject-2.0 -lpango-1.0 -lpangoft2-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lcairo -latk-1.0 -lpangocairo-1.0 -lgdk-x11-2.0 -lgtk-x11-2.0 -lrt -lpthread -lm -ldl -lstdc++
I'm getting these errors:
:-1: error: cannot find -ljasper
:-1: error: cannot find -ltiff
:-1: error: cannot find -ljpeg
:-1: error: cannot find -lgdk_pixbuf-2.0
EDIT:
In reality I'm programming for research purpose, and I m in image processing and pattern recognition, first I was on my computer doing small tests, but now I must do tests on a large database and this is very time comsuming thats why I want to use a cluster and the problem is that the cluster does'nt have opencv that's why I want to bring my .exe
To simplify things I make a small program with main only and some simple function (where figure all the header I used in my program)
headers are:
#include "opencv2/core/core.hpp"
#include "math.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
I put this line in my project.pro to identify the minimal dependencies :
LIBS += -L/usr/local/lib -lopencv_imgproc -lopencv_highgui -lopencv_core
this works correctly but when I add the parametre :
QMAKE_LFLAGS += -static
I have many many erros like:
grfmt_tiff.cpp:-1: error: undefined reference to `TIFFSetErrorHandler'
..
grfmt_jpeg.cpp:-1: error: undefined reference to `jpeg_start_decompress'
..
grfmt_exr.cpp:-1: error: undefined reference to `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)'
..
grfmt_png.cpp:-1: error: undefined reference to `png_create_write_struct'
..
grfmt_jpeg2000.cpp:-1: error: undefined reference to `jas_cleanup'
..
system.cpp:-1: error: undefined reference to `pthread_spin_init'
persistence.cpp:-1: error: undefined reference to `gzeof'
rand.cpp:-1: error: undefined reference to `pthread_once'
..
(.text._ZNSt12_GLOBAL__N_13runEv+0x1d):-1: error: undefined reference to `pthread_setspecific'
After installing what you tell me to install
sudo apt-get install libjasper-dev libtiff-dev libjpeg-dev libgtk2.0-dev
And adding this lines in my .pro
LIBS += -L/usr/lib/x86_64-linux-gnu -ltiff -ljpeg -lpthread -lpng -ljasper -ljbig -lz -llzma
LIBS += -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf
I had dimunuate the issues to be 63 this error are like :
grfmt_png.cpp:-1: error: undefined reference to `png_set_longjmp_fn'
(.text+0x27a):-1: error: undefined reference to `deflateParams'
IlmThreadMutexPosix.cpp:-1: error: undefined reference to `pthread_mutex_destroy'
IlmThreadPosix.cpp:-1: error: undefined reference to `pthread_join'
ImfZipCompressor.cpp:-1: error: undefined reference to `compress'
(.text+0x185e):-1: error: undefined reference to `pthread_mutex_lock'
ImfPxr24Compressor.cpp:-1: error: undefined reference to `compress'
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.2+0x1d):-1: error: undefined reference to `pthread_mutex_lock'
Here is the simplified code source :
#include <iostream>
#include "opencv2/core/core.hpp"
#include "math.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include <iostream>
#include <fstream>
using namespace std;
const double PI_2=atan (1.0)*2.0;
const double PI=atan (1.0)*4.0;
const double PI_4=atan (1.0);
const double PI3_4=PI_2+PI_4;
/*
void Paint_rect(){
cv::Mat imgq=cv::imread("/home/touka/Documents/PalmPrintProject/new-100-bmp-183-187/1_1.jpg",CV_LOAD_IMAGE_COLOR);
cv::Mat imgt=imgq.clone();
cv::rectangle(imgt,cv::Point (150,150),cv::Point (874,874),CV_RGB(255,0,0),2);
cv::imwrite("/home/touka/Desktop/test2.jpg",imgt);
}
void Save_Ort_Mat_File (cv::Mat mt, string file_name){
ofstream myfile;
myfile.open (file_name.c_str());
if(myfile){
for (int i=0;i<mt.rows;i++){
for (int j=0;j<mt.cols; j++)
myfile <<setprecision(8)<< ((mt.at<double>(i,j)*180)/PI)<<" | ";
myfile <<"\n" ;}
myfile.close();}
else{
cout <<"ERROR0";
}
}
*/
cv::Mat Sobel_Gradient_Image (cv::Mat img){
cv::Mat GX,GY,GXY;
cv::Point P(-1,-1);
cv::Vec3d X(1,2,1);
cv::Vec3d Y(1,0,-1);
cv::sepFilter2D(img,GX,img.depth(),Y,X,P,0,cv::BORDER_CONSTANT);
cv::sepFilter2D(img,GY,img.depth(),X,Y,P,0,cv::BORDER_CONSTANT);
vector<cv::Mat> m;
m.push_back(GX); m.push_back(GY);
cv::merge(m,GXY);
return GXY;
}
int main(int argc, char *argv[])
{
cv::Mat test;
cv::Mat imgq=cv::imread("/home/touka/Documents/PalmPrintProject/new-100-bmp-183-187/1_1.jpg",CV_LOAD_IMAGE_COLOR);
// test= Sobel_Gradient_Image(imgq);
// Paint_rect();
// Save_Ort_Mat_File(test,"file");
cout << "Hello World!" << endl;
return 0;
}
EDIT
Affter changing order of library and adding -pthread I finished by having only one error repeated 3 times:
png.cpp:-1: error: undefined reference to `png_set_longjmp_fn'
I don't Know why this error is repeated 3 times Here is the new order:
LIBS += -L/usr/local/lib -lopencv_imgproc -lopencv_highgui -lopencv_core
LIBS += -L/usr/local/share/OpenCV/3rdparty/lib -lIlmImf
LIBS += -L/usr/lib/x86_64-linux-gnu -lpng -ljasper -ltiff -ljpeg -lpthread -ljbig -llzma -pthread -lz
I tried adding CONFIG += staticlib on my project.pro but I had remarked that it's still using the dynamic library
You use this when you want to tell QMake that you are intending your build target itself to be a static library. But you want a console application. See the section with staticlib in it here in QMake's CONFIG documentation
First I was using OpenCV dynamically (using an .so) But I want to execute my application on PCs that don't have OpenCV installed.
In order to replace functionality that was previously provided by a dynamic library, you will need to have all the build dependencies of that library installed (e.g. the xxx-dev packages whoever compiled that .so was using).
I'm really not sure exactly what you're building or what dependencies are legitimate or not. It really helps if you can come up with a Minimal, Complete, Verifiable Example when asking questions. It makes a big difference if you have a tiny program that includes OpenCV, has a main(), and a QMake file that tries to build it...and demonstrates your error, vs. an example others can't see or test!
But...you could try removing those -lxxx lines for the missing libraries and see what happens. If you get link errors from functions which sound like they would be from those libraries, then they are actually needed as a dependency in your app.
But otherwise, just pushing along, you might try:
sudo apt-get install libjasper-dev libtiff-dev libjpeg-dev libgtk2.0-dev
I'm trying to run a example code from here.
I've installed the boost library by using
sudo apt-get install libboost-all-dev
and I've included it into my project like this:
QMAKE_CXXFLAGS += -std=c++0x -pthread
LIBS += -lpthread
LIBS += -lboost_system
(using QtCreator).
But I'm still getting the following error-messages:
/usr/lib/x86_64-linux-gnu/qt5/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../websocket/websocket.pro
g++ -m64 -o websocket main.o -lpthread -lboost_system
main.o: In function `websocketpp::random::random_device::int_generator<unsigned int, websocketpp::concurrency::basic>::~int_generator()':
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:53: undefined reference to `boost::random::random_device::~random_device()'
main.o: In function `websocketpp::random::random_device::int_generator<unsigned int, websocketpp::concurrency::basic>::int_generator()':
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:60: undefined reference to `boost::random::random_device::random_device()'
/home/alex/C++/build-websocket-Desktop-Debug/../websocket/websocketpp/random/random_device.hpp:60: undefined reference to `boost::random::random_device::~random_device()'
main.o: In function `boost::asio::detail::chrono_time_traits<boost::chrono::steady_clock, boost::asio::wait_traits<boost::chrono::steady_clock> >::now()':
/usr/include/boost/asio/detail/chrono_time_traits.hpp:45: undefined reference to `boost::chrono::steady_clock::now()'
main.o: In function `unsigned int boost::random::detail::generate_uniform_int<boost::random::random_device, unsigned int>(boost::random::random_device&, unsigned int, unsigned int, mpl_::bool_<true>)':
/usr/include/boost/random/uniform_int_distribution.hpp:66: undefined reference to `boost::random::random_device::operator()()'
/usr/include/boost/random/uniform_int_distribution.hpp:114: undefined reference to `boost::random::random_device::operator()()'
/usr/include/boost/random/uniform_int_distribution.hpp:201: undefined reference to `boost::random::random_device::operator()()'
collect2: error: ld returned 1 exit status
make: *** [websocket] Error 1
15:41:25: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project websocket (kit: Desktop)
When executing step 'Make'
15:41:25: Elapsed time: 00:00.
There also seem to be problems with the websocketpp library, but I think they are based on boost, too.
Thanks!
You also need:
LIBS+=-lboost_random
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 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?