1
我安装了BOOST 1.57以允许使用一些新功能,因此我只创建了一个包含根BOOST文件夹的目录/usr/local/boost
。在Qt中包含共享内存BOOST库
我已经成功地创造出here的示例代码和使用编译:
g++ example.cpp -o example -lrt
这里是我的.pro文件:
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
,这里是我的错误:
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 '[email protected]@GLIBC_2.2.5'
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: note: '[email protected]@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
只是要注意以前的所有skipping
警告之前都很好,它只是这个最后的'[email protected]@GLIBC_2.2.5'
这似乎打破了它。
所有我加的是:
#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
);
进入我的文件之一。
任何想法是怎么回事?
编辑:
添加:
LIBS += -L/usr/local/boost/libs -lrt
给了我新的错误:
/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
完成,它扔了一个新的错误 – fiz 2015-02-10 15:59:59
您还需要'-lboost_system'以同样的方式(可能更多)(搞笑,我不回想一下使用'shared_memory_object'来调用_just_) – sehe 2015-02-10 16:00:56
它的工作,谢谢。如果问题的格式不错,请随时与我联系。 – fiz 2015-02-10 16:01:35