Is it possible to compile Poco libs such that I can use them on Raspberry Pi with my Qt project? Currently I have my Qt project up and running on Raspberry Pi except for the functions using Poco. I thought that I could compile Poco directly on Raspberry Pi and just copy the compiled libs and header files to my Ubuntu machine, which does the compiling of my Qt project. I included
INCLUDEPATH += /path/to/poco/libs/compiled/for/raspberrypi/include
DEPENDPATH += /path/to/poco/libs/compiled/for/raspberrypi/include
LIBS += -L/path/to/poco/libs/compiled/for/raspberrypi -lPocoFoundation -lPocoNet
target.path = /home/pi/path/to/my/executable
INSTALLS += target
in my .pro file.
But I get the following error the first time the compiler encounters a Poco include:
/home/jon/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++ -c -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/mnt/rasp-pi-rootfs -g -std=c++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_PLUGIN -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g++ -I../../../BeatQtPlayer/src/pocowebserverplugin -I../../../BeatQtPlayer/src -I/home/jon/tmp/BeatQtPlayer/src/pocowebserverplugin/../../external_tools/poco-1.4.6p2/lib_raspberrypi/include -I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include -I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include/QtNetwork -I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include/QtCore -I. -I. -o pocowebserverplugin.o ../../../BeatQtPlayer/src/pocowebserverplugin/pocowebserverplugin.cpp
In file included from ../../../BeatQtPlayer/src/pocowebserverplugin/pocowebserverplugin.h:5:0,
from ../../../BeatQtPlayer/src/pocowebserverplugin/pocowebserverplugin.cpp:1:
../../../BeatQtPlayer/src/pocowebserverplugin/requesthandler.h:4:48: fatal error: Poco/Net/HTTPRequestHandlerFactory.h: No such file or directory
compilation terminated.
Ensure that you have set up your include paths for the Poco library itself correctly. Poco internal headers may need other directories than the root '/path/to/.../include/' path to be included into the include path.
These are the include paths your compiler is looking at. Is Poco/Net in there somewhere?
-I/usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g++
-I../../../BeatQtPlayer/src/pocowebserverplugin
-I../../../BeatQtPlayer/src
-I/home/jon/tmp/BeatQtPlayer/src/pocowebserverplugin/../../external_tools/poco-1.4.6p2/lib_raspberrypi/include
-I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include
-I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include/QtNetwork
-I/mnt/rasp-pi-rootfs/usr/local/qt5pi/include/QtCore
-I.
-I.
Related
I am trying to make Jenkins do the compile and build for me whenever I push commit to Git. I have a helloworld app created in Qt Creator. It does compile and build in Qt Creator, it does show on my phone, but it doesn't want to compile and build with Jenkins.
I am using the same shell commands which QtC used:
qmake helloworld.pro -r -spec android-g++;
make;
The console output is:
+ qmake helloworld.pro -r -spec android-g++
+ make
/home/ndk/toolchains/arm-linux-androideabi-4.9-/prebuilt/bin/arm-linux-androideabi-g++ -c -pipe -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -I/usr/share/qt4/mkspecs/android-g++ -I. -I. -I/home/ndk/sources/cxx-stl/gnu-libstdc++//include -I/home/ndk/sources/cxx-stl/gnu-libstdc++//libs//include -I/home/ndk/platforms//arch-arm//usr/include -o main.o main.cpp
In file included from main.cpp:1:0:
mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
#include <QMainWindow>
^
compilation terminated.
Makefile:187: recipe for target 'main.o' failed
make: *** [main.o] Error 1
My helloworld.pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworld
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY =
main.cpp
#include "mainwindow.h"
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
EDIT/UPDATE:
So far, I have tried to specify the full path to qmake, to be sure that I use Qt's qmake.
/home/qt/5.7/android_armv7/bin/qmake helloworld.pro -r -spec android-g++;
make;
The output is:
/home/qt/5.7/android_armv7/bin/uic mainwindow.ui -o ui_mainwindow.h
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o main.o main.cpp
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o mainwindow.o mainwindow.cpp
mainwindow.cpp:3:25: fatal error: QtGui/QAction: No such file or directory
#include <QtGui/QAction>
^
compilation terminated.
Makefile:1780: recipe for target 'mainwindow.o' failed
make: *** [mainwindow.o] Error 1
Most likely your jenkins setup uses the wrong qmake. There's a 1:1 mapping between a Qt installation and its qmake. So, your install of Qt for android will have its own qmake that you must refer to by full path! Qt Creator sets up the path so that this happens automatically, Jenkins doesn't - and it shouldn't anyway.
When building for any particular Qt version, you only need to invoke its qmake explicitly. From then onwards, as long as the proper compiler is in the path, things will happen as they should and you don't ever need to refer to that Qt version manually again. The makefiles will all refer to Qt libraries, headers and tools from that Qt install.
You also don't need the -spec argument. Each Qt installation is compiled for a particular mkspec, so qmake itself knows exactly what the spec is. I have no idea why QtCreator gives that argument, it doesn't make much sense.
The only Qt header path that's in your commandline is the one for the mkspec. I would blame the server's Qt installation for this.
Ensure Qt for Android is properly installed on the server, and that it is its qmake you are calling.
I'm currently working on an R package which uses C++ code and includes external libraries (dlib, boost and an optimization library developed in the group). We're using Rcpp to integrate R and C++, but the problem is the package always fails to compile, and none of the similar questions I've found out there have worked for me.
The report generated by R CMD check is:
* installing *source* package 'IRTppExperimental' ...
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Users/Camilo/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -I../src/include -O2 -Wall -mtune=core2 -c test_multi.cpp -o test_multi.o
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o IRTppExperimental.dll tmp.def RcppExports.o rcpp_hello_world.o test_multi.o -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lRlapack -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lRblas IRTppExperimental.dll -L../src/include -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/i386 -lR
g++.exe: error: IRTppExperimental.dll: No such file or directory
no DLL was created
ERROR: compilation failed for package 'IRTppExperimental'
* removing 'C:/Users/Camilo/Documents/UNAL/MIRT/Tests/Temps/IRTppExperimental.Rcheck/IRTppExperimental'
And the Makevars/Makevars.win files are as follows:
INCFOLDER = ../src/include
PKG_LIBS += $(LAPACK_LIBS) $(BLAS_LIBS) $(FPICFLAGS) $(SHLIB)
PKG_LIBS += -L$(INCFOLDER)
PKG_CXXFLAGS+=-I$(INCFOLDER)
CXXFLAGS+="-fno-stack-protector"
CXX_STD = CXX11
Lastly, the NAMESPACE file reads:
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp,sourceCpp)
useDynLib(IRTppExperimental)
All the c++ source files are inside the src folder, including the external libraries. The package was created using the Rcpp.package.skeleton function, and used the compileAtributes function to create the RcppExports source files.
EDIT: As pointed out by Coatless, here is github link of the project: https://github.com/SICSresearch/IRTpp/tree/Uni-Multi-Merging
I'm porting an application qt3 -> qt5. As part of that I have in a .cpp file changed (Qt3)
mySystemstruct.display = theWidget->x11Display();
into (Qt5)
mySystemstruct.display = QX11Info::display();
Include has been added in the file.
#include <QX11Info>
I am not using Qt Creator. The file in question is not been linked using qmake. (other files has)
I get this link errors:
/home/go/NetBeansProjects/Arbete_216/Ajourwork/Components/TheRealDeal/GUI/linuxobj//GO_C_QtGUI.o: In function `GO_C_QtGUI::initHistoryFilm(QWidget*, int, int)':
/home/go/NetBeansProjects/Arbete_216/Ajourwork/Modules/GUI/QtGUI/GO_C_QtGUI.cpp:668: undefined reference to `QX11Info::display()'
using this compile command:
clang++ -o gvs_GUI linuxobj/*.o linuxobj/libQtSpecific.a -DLINUX -I/include/ -g -I /opt/intel/composer_xe_2015.1.133/ipp/include/ -Wno-deprecated -D_GNU_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -I/usr/include/postgresql/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtX11Extras/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtWidgets/ -I/usr/local/Qt/5.2.1/gcc_64/include/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtGui/ -fPIC -fPIE -I/home/go/ffmpeg_build/include/ -I/usr/local/Qt/5.2.1/gcc_64/include/QtCore/ -fPIC -fPIE -I/home/go/ffmpeg_build/include/libavcodec -I/home/go/ffmpeg_build/include/libavformat/ -lpq -lippi -lipps -lippcore -lpthread -lgcrypt -lippvm -lippcv -lippcc -L/opt/intel/composer_xe_2015.1.133/ipp/lib/intel64 -L/usr/local/Qt/5.2.1/gcc_64/lib/ -L/usr/X11R6/lib/ -lXv -lX11 -lXext -ltar -lavformat -lavcodec -lavfilter
Is it not possible to build using Qt libs not using qmake? My code has been built that way with earlier versions of Qt so it seems it should work.(?)
Since not using qmake for linking, I use -I/usr/local/Qt/5.2.1/gcc_64/include/QtX11Extras/ -L/usr/local/Qt/5.2.1/gcc_64/lib/ but it doesn't seem to work.
The QtX11-lib seems to be in place:
locate libQt5X11Extras.so
/usr/local/Qt/5.2.1/gcc_64/lib/libQt5X11Extras.so
/usr/local/Qt/5.2.1/gcc_64/lib/libQt5X11Extras.so.5
/usr/local/Qt/5.2.1/gcc_64/lib/libQt5X11Extras.so.5.2
/usr/local/Qt/5.2.1/gcc_64/lib/libQt5X11Extras.so.5.2.1
What am I doing wrong here?
-L/usr/local/Qt/5.2.1/gcc_64/lib/ only tells the linker where to find the libraries.
You must then add -lQt5X11Extras to ask to link to the Qt5X11 library.
I get a strange error while building my Qt C++ project on Ubuntu Linux using GCC 5.2.1:
/usr/bin/ld: cannot find -llibmath
I include external dynamic library to maky qmake project using command:
LIBS += -L/home/rem -llibmath
and I have library file at path /home/rem/libmath.so
As I can see from compiler output:
g++ -Wl,-rpath,/home/rem/Qt/5.5/gcc_64 -Wl,-rpath,/home/rem/Qt/5.5/gcc_64/lib -o Bazis main.o builder.o -L/home/rem -llibmath -L/home/rem/Qt/5.5/gcc_64/lib -lQt5OpenGL -L/usr/lib64 -lQt5QuickWidgets -lQt5Widgets -lQt5Quick -lQt5Gui -lQt5Sql -lQt5Test -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread
all parameters are correctly send by qmake to g++.
What is the source of my problem?
The solution is simple:
I changed my .pro file from:
LIBS += -L/home/rem -llibmath
to:
LIBS += -L/home/rem -lmath
I am trying to compile a project in my system using qmake. Some dependencies of the project are not installed but reside in my home directory, more or less like this: libs files: /home/myusername/local/lib and my includes directory /home/myusername/local/include. Inside the include directory I have a folder, qjson with the needed headers from the library. In the lib folder I have the files libqjson.so libqjson.so.0 libqjson.so.0.7.1.
My qmake project file looks something like this:
linux-g++ {
INCLUDEPATH += /home/myusername/local/include/
LIBS += -L/home/myusername/local/lib/ -lqjson
}
and the generated makefile will produce commands like this one:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB \
-DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../qbuzz \
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui \
-I/usr/include/qt4 -I/home/myusername/local/include/ -I. -I. -I../myproject -I. \
-o qbuzz-result.o ../myproject/myfile.cc
It is clear that my include directory is in the -I option of gcc. myfile.cc contains an include like this one:
#include <qjson/parser.h>
However, after running make, I get the error:
../myproject/myfile.cc:2:26: fatal error: qjson/parser.h: No such file or directory
compilation terminated.
Now, if I modify the environment variable CPLUS_INCLUDE_PATH to add my local include file, I have no problems there, but in the linker stage I got the error:
/usr/bin/ld: cannot find -lqjson
collect2: ld returned 1 exit status
Even though the linker command was:
g++ -omyprogram main.o mainwindow.o myfile.o moc_mainwindow.o -L/usr/lib \
-L/home/myusername/local/lib/ -lqjson -lQtGui -lQtNetwork -lQtCore -lpthread
I also can get around modifying the environment variable LIBRARY_PATH. However I am looking for a solution that relies on modifying as few environment variables as possible, and after all, why are the options -L and -I there?
I works on Windows without problems using MinGW g++.
I notice that the QT's automatic include paths have no trailing slashes, and yours do. Have you tried writing the paths without trailing slashes?
linux-g++ {
INCLUDEPATH += /home/myusername/local/include
LIBS += -L/home/myusername/local/lib -lqjson
}
G++ and friends (i.e. as, ld, etc) will not directly tell you exactly where it looks for header and library files. One way to debug this is to run strace -o output.txt -eopen -s 1024 -f qmake. This will run qmake logging all open system calls of qmake and all of the child processes it forks. You will then be able to see in what directories and in what order it searches for header files (and libraries). Example output extract for stdio.h:
26069 open("/usr/lib/gcc/x86_64-redhat-linux/4.6.0/include/stdio.h", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
26069 open("/usr/local/include/stdio.h", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
26069 open("/usr/include/stdio.h", O_RDONLY|O_NOCTTY) = 4