I'm a relatively new user of QTCreator, I've used the standard and QT libraries before but this is the first project I'm trying to
add a exterior library and I'm having problems.
I'm trying to use the Point Cloud Library and as far as I can tell I installed it correctly in usr/lib yet when I try to do this simple tutorial the includes won't work:
#include <boost/thread/thread.hpp>
#include <pcl/common/common_headers.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/console/parse.h>
Gives me this error:
/home/george/Documents/QT/EditorPCL-build-desktop-Qt_4_8_1_in_PATH__System__Release/../EditorPCL/editor.cpp:7: error: pcl/common/common_headers.h: No such file or directory
Now I added the libraries through the GUI so syntactically I think the QMake file is correct but I don't have any ideea what's wrong.
Here is the relevant portion of the QMake file:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_visualization
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_visualizationd
else:symbian: LIBS += -lpcl_visualization
else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_visualization
INCLUDEPATH += $$PWD/../../../../../usr/lib
DEPENDPATH += $$PWD/../../../../../usr/lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/release/ -lpcl_common
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/debug/ -lpcl_common
else:symbian: LIBS += -lpcl_common
else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_common
INCLUDEPATH += $$PWD/../../../../../usr/lib
DEPENDPATH += $$PWD/../../../../../usr/lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/release/ -lpcl_apps
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/debug/ -lpcl_apps
else:symbian: LIBS += -lpcl_apps
else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_apps
INCLUDEPATH += $$PWD/../../../../../usr/lib
DEPENDPATH += $$PWD/../../../../../usr/lib
Your error is thrown by the compile while it is trying to find headers.
... error: pcl/common/common_headers.h: No such file or directory
That tells me that it is not finding the proper include path. Looking at your QMake file, I see you are setting your include path to
INCLUDEPATH += $$PWD/../../../../../usr/lib
On most Linux/Unix (and even Windows) systems, the includes are not in the subdirectory lib, but instead they are in the subdirectory include.
Additionally, I do not like how you specified your both your LIBPATH and INCLUDEPATH. They will work if both the PWD and the installed location of the files never move. A better suggestion (at least for Unix/Linux) is to use the pkg-config utility. You might want to read the article Using pkg-config with Qmake and see if it will help.
Related
Good day. I am trying to set up my Qt Creator to use Magick++. I've added
INCLUDEPATH += /usr/local/Cellar/imagemagick/7.0.8-23/include/ImageMagick-7
And that sort of worked, I can now add
#include <Magick++.h>
It does autocomplete and everything. But I get a lot of warnings that I am supposed to set MAGICKCORE_QUANTUM_DEPTH and MAGICKCORE_HDRI_ENABLE to sensible values. I have no idea what it is and how to do it. I've tried to research this topic but only found that I need to add Lib files like this:
QMAKE_CXXFLAGS += $(shell Magick++-config --cppflags --cxxflags)
LIBS += $(shell Magick++-config --ldflags --libs)
but that only added an error: :-1: error: Magick++-config: Command not found
I am using the latest version of Qt creator. ImageMagick-7. Mac OSX Mojave
Both MAGICKCORE_QUANTUM_DEPTH & MAGICKCORE_HDRI_ENABLE must be added to qmake's DEFINES variable.
Try the following...
QMAKE_CXXFLAGS += $(shell Magick++-config --cxxflags)
LIBS += $(shell Magick++-config --libs)
DEFINES += "MAGICKCORE_QUANTUM_DEPTH=16"
DEFINES += "MAGICKCORE_HDRI_ENABLE=1"
... assuming you are running ImageMagick-7 Q16 HDRI library.
as the title indicates, I am trying to compile a simple project in Qt that makes use of the addressbook.pb.h/addressbook.pb.cc files that are generated in the google protobuf3 tutorial for C++ users. Here is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2016-11-07T10:33:12
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = prototest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
../protobuf/examples/addressbook.pb.cc
HEADERS += mainwindow.h \
../protobuf/examples/addressbook.pb.h
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/Cellar/protobuf/3.1.0/include
LIBS += /usr/local/Cellar/protobuf/3.1.0
Unfortunately, this throws
:-1: error: can't map file, errno=22 file '/usr/local/Cellar/protobuf/3.1.0' for architecture x86_64
I'm stuck at this point. Any help would be greatly appreciated. I have been able to compile and run the exact same (addressbook.*) files using Xcode8.
Solved it: Add the following to the .pro file
macx: LIBS += -L$$PWD/../../../usr/local/Cellar/protobuf/3.1.0/lib/ -lprotobuf.11
INCLUDEPATH += $$PWD/../../../usr/local/Cellar/protobuf/3.1.0/include
DEPENDPATH += $$PWD/../../../usr/local/Cellar/protobuf/3.1.0/include
I should add how I arrived at this answer. Right click your project and select "Add Library->External Library", select your platform and enter your specific library (not path) that you want to add, and your include path (the options it gives you indicate such). Qt will generate the code and automatically add it to your .pro file.
I am currently trying to use OpenCV in a Qt project. When I build it, i get the error:
error: 'opencv2/opencv.hpp' file not found
#include <opencv2/opencv.hpp>
I know that there are many similar questions out there in the web, but none of the answers was actually able to fix my problem so far.
My specifications:
Qt 5.4.0 (Clang 6.0 (Apple), 64 bit)
Mac OSX 10.10.1
OpenCV 2.4.9 installed from homebrew
My .pro file looks like this:
QT += core gui multimedia multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MainProject
TEMPLATE = app
SOURCES += main.cpp mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/include/opencv2
LIBS += -L/usr/local/lib
LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
LIBS += -lopencv_ml
LIBS += -lopencv_video
LIBS += -lopencv_features2d
LIBS += -lopencv_calib3d
LIBS += -lopencv_objdetect
LIBS += -lopencv_contrib
LIBS += -lopencv_legacy
LIBS += -lopencv_flann
I made sure the links actually link to the right locations. All the header files and all the .dylib files are there as well. I checked the type of the libraries:
$ file libopencv_core.dylib
libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64
In my project settings, the qmake command is:
qmake: qmake MainProject.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64
Unfortunately I only have a basic understanding of these compile-things, so I am not too sure, whether it has something to do with clang? I read something about clang behaving somehow different on OSX 10.10 Yosemite, but I did not completely understand why. Info about my clang:
$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
I also tried to use the gcc-kit in Qt (GCC x86 64bit in /usr/bin), but this messed up a lot more, which I did not understand.
Does somebody have an idea what I am doing wrong? Any help appreciated!
Patrick
You are already including the directory opencv2 in your #include statement. You should change your include path to just INCLUDEPATH += /usr/local/include.
I am trying to compile a open source project on windows: https://github.com/francisengelmann/FabScan100
I am using QtCreator 2.7.0, Qt Qt5.0.2 msvc2010_opengl, MSVC2010
My direcotries look like this:
C:\
C:\libs\opencv-2.4.2\
C:\libs\pcl-1.6.0
C:\libs\Qt\Qt5.0.2
C:\fabscan\FabScan100-master
I modified the qtTest.pro file to include the neccessary headers and libs:
INCLUDEPATH += C:\libs\pcl-1.6.0\3rdParty\Eigen\include
LIBS += C:\libs\pcl-1.6.0\3rdParty\Eigen\bin
INCLUDEPATH += C:\libs\pcl-1.6.0\3rdParty\FLANN\include\flann
LIBS += C:\libs\pcl-1.6.0\3rdParty\FLANN\lib
INCLUDEPATH += C:\libs\pcl-1.6.0\3rdParty\Boost\include\boost
LIBS += C:\libs\pcl-1.6.0\3rdParty\Boost\lib
INCLUDEPATH += C:\libs\opencv-2.4.2\opencv\build\include
LIBS += C:\libs\opencv-2.4.2\opencv\build\x86\vc10\lib
INCLUDEPATH += C:\libs\pcl-1.6.0\include\pcl-1.6
LIBS += C:\libs\pcl-1.6.0\lib \
-lpcl_common \
-lpcl_io \
-lpcl_filters \
-lpcl_kdtree \
-lpcl_registration \
-lpcl_features \
-lpcl_segmentation \
-lpcl_surface \
-lpcl_search
But when I press the compile button QtCreator throws me an error:
..\qtTest\staticHeaders.h(4) : fatal error C1083: Cannot open include file: 'Eigen/Core': No such file or directory
Which is kind of strange because the file is actually there. I am also able to open it in QtCreator by pressing STRG & Clicking on the include statement in staticHeaders.h
Any ideas?
Based on the staticHeaders.h code (line 4), you need to have a folder called "Eigen" which contains the "Core" file. For instance, I have /usr/include/eigen2/Eigen/Core on Linux, in which case /usr/include/eigen2 has to be added to the INCLUDEPATH variable with qmake. Make sure you have C:\libs\pcl-1.6.0\3rdParty\Eigen\include.
Also, if it does not work in QtCreator as per your comment, you can always try to force explicitly to rerun qmake by the execute qmake option.
I have compiled TBB from source using Mingw following the comment #5 in this post: http://software.intel.com/en-us/forums/topic/291331. That went ok.
When I try to use the new TBB library in a QtCreator project, I end with this errors (ignore the warning messages): http://postimage.org/image/yrrecugix/
Here's the sample code I tried (I omit the non-tbb code):
#include "tbb/task_scheduler_init.h"
int main()
{
tbb::task_scheduler_init init;
/// more things.
}
And here's the .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.cpp
#QMAKE_CXXFLAGS += -fopenmp
#QMAKE_LFLAGS += -fopenmp
INCLUDEPATH += "E:\TRABAJO\LIBRERIAS\tbb-4.1_src\include"
LIBS += -L"E:\TRABAJO\LIBRERIAS\tbb-4.1_src\build\windows_intel64_gcc_mingw4.5.4_debug\" \
-ltbb_debug
Any idea?.
Thanks!.
When built with MinGW on Windows, TBB binaries are tbb.dll and tbb_debug.dll. The option -ltbb_debug in your configuration files probably causes the linker to look for libtbb_debug.<something>. It can't find such a binary and reports about unresolved symbols.