I'm trying to create a quick GUI which will act as a frontend for some software written by someone else. The problem I'm having seems to be a library issue but I'm going around in circles with the error. Any suggestions on what the error means or what I can try would be greatly appreciated.
~/Ph2_DAQ
Inside this I have the many folders but the ones I refer to are:
lib/ src/ TestStand/
This is the .pro file I've made in /TestStand
which needs to be compiled in 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
To test I can call in a special external library which I know I will need, I add this to my main.cpp
:
#include "uhal/uhal.hpp"
I run qmake
on this and I get a few warnings and errors once I run make
in the directory that all look pretty similar:
/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 ];
It then sends a few erros that it can't find my custom libraries despite them being there:
/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)
and if I do the ls
command:
ls ../lib/
libPh2_Description.so libPh2_System.so libPh2_Tools.so
The software has this Makefile
which has this structure, so I naturally tried copying parts since the software does compile on my computer:
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
Before the warnings:
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,...
And After the warnings:
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
This is the output from the software (not the GUI) when it compiles correctly using the above makefile:
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
What is the current current directory of your make? Are you using shadow-build option, which generated a build-directory next to your application directory. When using relative library-paths these can getting wrong. So try to use absolute paths or adapt the
../lib
to a relative path, which matches to the lib directory.
And can you show the output in your console for the ld-step. I am not sure, feels like the library paths are not set correctly. Does it works when you write:
LIBS += -L/opt/xdaq/lib
LIBS += -lcactus_extern_pugixml -lcactus_uhal_log -lcactus_uhal_grammars -lcactus_uhal_uhal
instead?