我试图创建一个快速的GUI,它将作为其他人编写的某些软件的前端。我遇到的问题似乎是图书馆问题,但我带着错误绕圈子走了。任何有关错误含义或我可以尝试的建议都将不胜感激。
~/Ph2_DAQ
在这里我有很多文件夹,但我所指的是:
lib/ src/ TestStand/
这是我在/TestStand
中创建的.pro文件,需要在C ++ 11中编译:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestStand
TEMPLATE = app
QMAKE_CXXFLAGS += -pedantic -std=c++11 `root-config --cflags --evelibs` #Added these flags
INCLUDEPATH += /opt/cactus/include ../
#LIBS += -L/opt/xdaq/lib
#LIBS += -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal
LibraryDirs = /opt/cactus/lib /opt/xdaq/lib ../lib #/***Added to the generated file from here...
LibraryPaths = $(LibraryDirs:%=-L%)
LIBS += $(LibraryPaths:%=-L%) -uhal -lboost_system -lboost_thread -lpthread -lboost_regex -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal `root-config --glibs` -lPh2_Interface -lPh2_Description -lPh2_System -lPh2_Tools #***/ ... To here
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
为了测试我可以调用一个我知道需要的特殊外部库,我将其添加到我的main.cpp
:
#include "uhal/uhal.hpp"
我在此运行qmake
,一旦我在所有看起来非常相似的目录中运行make
,我会收到一些警告和错误:
/usr/local/Trolltech/Qt-4.8.5/bin/uic mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -pedantic -std=c++11 `root-config --cflags --evelibs` -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include -I/opt/cactus/include -I.. -I. -I. -o main.o main.cpp
In file included from /opt/cactus/include/boost/bind/bind.hpp:29:0,
from /opt/cactus/include/boost/bind.hpp:22,
from /opt/cactus/include/boost/thread/detail/thread.hpp:29,
from /opt/cactus/include/boost/thread/thread.hpp:22,
from /opt/cactus/include/boost/thread.hpp:13,
from /opt/cactus/include/uhal/log/exception.hpp:50,
from /opt/cactus/include/uhal/ValMem.hpp:43,
from /opt/cactus/include/uhal/uhal.hpp:40,
from main.cpp:3:
/opt/cactus/include/boost/bind/arg.hpp: In constructor âboost::arg<I>::arg(const T&)â:
/opt/cactus/include/boost/bind/arg.hpp:37:22: warning: typedef âT_must_be_placeholderâ locally defined but not used [-Wunused-local-typedefs]
typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
然后它会发送一些错误信息,即使它们在那里也无法找到我的自定义库:
/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: cannot find -lPh2_Description #(and the same for -lPh2_System & lPh2_Tools)
如果我执行ls
命令:
ls ../lib/
libPh2_Description.so libPh2_System.so libPh2_Tools.so
软件有Makefile
这个结构,所以我自然会尝试复制部件,因为软件在我的电脑上编译:
CC = gcc
CXX = g++
CCFlags = -g -O1 -w -Wall -pedantic -fPIC `root-config --cflags --evelibs`
#DevFlags = -D__CBCDAQ_DEV__
DevFlags =
IncludeDirs = /opt/cactus/include ../
IncludePaths = $(IncludeDirs:%=-I%)
LibraryDirs = /opt/cactus/lib /opt/xdaq/lib ../lib
LibraryPaths = $(LibraryDirs:%=-L%)
ExternalObjects = $(LibraryPaths) -lpthread -lboost_thread -lboost_filesystem -lboost_regex -lboost_system -lboost_thread -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal `root-config --glibs` -lPh2_Interface -lPh2_Description -lPh2_System -lPh2_Tools
%.o: %.cc %.h
$(CXX) -std=c++11 $(DevFlags) $(CCFlags) $(UserCCFlags) $(CCDefines) $(IncludePaths) -c -o $@ $<
all: testpgrm datatest2cbc datatest8cbc mcp system calibrationtest
testpgrm: test.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
datatest2cbc: readdatatest2CBC.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
datatest8cbc: readdatatest8CBC.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
system: systemtest.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
mcp: mcp.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
calibrationtest: calibrationtest.cc
$(CXX) -std=c++11 $(CCFlags) -o $@ $< $(IncludePaths) $(ExternalObjects)
mv $@ ../bin
警告之前:
g++ -c -pipe -pedantic -std=c++11 root-config --cflags -evelibs -pthread -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include -I/opt/cactus/include -I.. -I. -I. -o main.o main.cpp In file included from /opt/cactus/include/boost/bind/bind.hpp:29:0,...
警告之后:
g++ -c -pipe -pedantic -std=c++11 `root-config --cflags --evelibs` -pthread -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include -I/opt/cactus/include -I.. -I. -I. -o mainwindow.o mainwindow.cpp
/usr/local/Trolltech/Qt-4.8.5/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include -I/opt/cactus/include -I.. -I. -I. mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -pedantic -std=c++11 `root-config --cflags --evelibs` -pthread -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include -I/opt/cactus/include -I.. -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp
g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.8.5/lib -o TestStand main.o mainwindow.o moc_mainwindow.o -L/usr/local/Trolltech/Qt-4.8.5/lib -L/opt/xdaq/lib -uhal -lboost_system -lboost_thread -lboost_regex -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal `root-config --glibs` -lPh2_Interface -lPh2_Description -lPh2_System -lPh2_Tools -lQtGui -L/usr/local/Trolltech/Qt-4.8.5/lib -L/usr/X11R6/lib -lQtCore -lpthread
这是使用上述makefile正确编译时软件(而不是GUI)的输出:
g++ -std=c++11 -g -O1 -w -Wall -pedantic -fPIC `root-config --cflags -evelibs` -o calibrationtest calibrationtest.cc -I/opt/cactus/include -I../ -L/opt/cactus/lib -L/opt/xdaq/lib -L../lib -lptost_thread -lboost_filesystem -lboost_regex -lboost_system -lboost_thread -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal `root-config --glibs` -lPh2_interfaceDescription -lPh2_system -lPh2_Tools
答案 0 :(得分:0)
您当前的当前目录是什么?您是否正在使用shadow-build选项,该选项在您的应用程序目录旁边生成了一个构建目录。使用相对库路径时,这些可能会出错。因此,尝试使用绝对路径或调整
../lib
到相对路径,与lib目录匹配。
您可以在控制台中显示ld-step的输出。我不确定,感觉库路径设置不正确。你写的时候它是否有效:
LIBS += -L/opt/xdaq/lib
LIBS += -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal
代替?