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.
Related
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.
There is lot's of information about configuring .pro file for Qt in linux to run GStreamer. But it looks so difficult to do the same in WINDOWS. I downloaded Gst from their official site and ran an installer. Now it's in D:\gstreamer\1.0\x86 ... I found the only description from someone who tried to change qt .pro file. I did the same:
INCLUDEPATH += c:/gstreamer/1.0/x86/include \
c:/gstreamer/1.0/x86/include/gstreamer-1.0/gst \
c:/gstreamer/1.0/x86/include/glib-2.0\
c:/gstreamer/1.0/x86/include/glib-2.0/glib \
c:/gstreamer/1.0/x86/lib/glib-2.0/include
LIBS += -Lc:/gstreamer/1.0/x86/lib
CONFIG += c:/gstreamer/1.0/x86/lib/pkgconfig
And the project find , gives assistance when typing "gst_init(" and other stuff for gstreamer but it gives an error
undefined reference to gst_init
Here is the question. How to connect GStreamer in windows?
#include <QCoreApplication>
#include <gst/gst.h>
int main(int argc, char *argv[])
{
gst_init(NULL,NULL);
//g_print("abc");
return 0;
}
C:/Qt/Qt5.1.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory
'D:/Projects/AllTests/Qt/build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug\Console.exe debug/main.o
-Lc:/gstreamer/1.0/x86/lib -LC:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib -lQt5Cored debug/main.o: In function main': D:\Projects\AllTests\Qt\build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../Console/main.cpp:8:
undefined reference togst_init' collect2.exe: error: ld returned 1
exit status Makefile.Debug:77: recipe for target 'debug\Console.exe'
failed mingw32-make[1]: * [debug\Console.exe] Error 1
mingw32-make[1]: Leaving directory
'D:/Projects/AllTests/Qt/build-Console-Desktop_Qt_5_1_1_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed mingw32-make: *
[debug] Error 2 00:20:18: Process
«C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\mingw32-make.exe» finishes with
code 2.
You have to specify the gstreamer libraries against which your binaries must be linked.
According to this documentation for qmake, by issuing LIBS += -Lc:/gstreamer/1.0/x86/lib you are instructing qmake to look for libraries within the given path, but not which of them to actually link to your binaries. I am not familiar with gstreamer, so I'm not sure what libraries must be linked in the specific case you presented, but I guess you'll find them all in gstreamer/1.0/x86/lib. If unsure you could add them all to the list prepending the lower case "l" to their names. For instance, if the library were called math, you'd add it by appending -lmath to the list. Just be cautious not to add multiple versions of the same library, say a debug version and a release version, at the same time, or you most certainly will get multiple reference linking errors.
Instead of manually specifying the libraries which should be linked to your binaries as suggested above, you also have the option to use pkg-config to do the hard work for you. This documentation for gstreamer states it suficies to add the following to the .pro file:
CONFIG += link_pkgconfig
PKGCONFIG += QtGStreamer-0.10
The drawback to this approach is naturally that you have to get pkg-config to work on your system first.
I find this works for me. It uses the environment variable set by the GStreamer install - so should work on other PCs. There is a different environment variable for 64 bit, but same principle.
QT += core gui
TARGET = GStreamerTest4
TEMPLATE = app
SOURCES += \
qt-videooverlay.cpp
HEADERS +=
FORMS +=
GstreamerDir=$$(GSTREAMER_1_0_ROOT_X86)
INCLUDEPATH = $${GstreamerDir}/include/gstreamer-1.0
INCLUDEPATH += $${GstreamerDir}/include/glib-2.0
INCLUDEPATH += $${GstreamerDir}/lib/glib-2.0/include
INCLUDEPATH += $${GstreamerDir}/lib/gstreamer-1.0/include
LIBS = $${GstreamerDir}/lib/gstreamer-1.0.lib
LIBS += $${GstreamerDir}/lib/*.lib
In addition, you need to make sure C:\gstreamer\1.0\x86\bin is on the path (control panel or you can set it in QtCreator).
I found that on windows you really can avoid pkg-config stuff bit than need to include everything is needed for gstreamer as libs and .h. But also you will need to include GTK. A good answer by Kei Naga provides the idea for qt in VS 2010 http://gstreamer-devel.966125.n4.nabble.com/Configure-Visual-Studio-2010-for-GStreamer-td3804989.html but if you transfer everything he wrote to .pro file it will also work (at least for me).
Here is the code of pro file:
INCLUDEPATH += C:/ ... /GStreamer/v0.10.6/sdk/include/gstreamer-0.10 \
C:/ ... /GTK/include/libxml2 \
C:/ ... /GTK/include/libglade-2.0 \
C:/ ... /GTK/lib/gtkglext-1.0/include \
C:/ ... /GTK/lib/glib-2.0/include \
C:/ ... /GTK/lib/gtk-2.0/include \
C:/ ... /GTK/include/gtkglext-1.0 \
C:/ ... /GTK/include/atk-1.0 \
C:/ ... /GTK/include/cairo \
C:/ ... /GTK/include/pango-1.0 \
C:/ ... /GTK/include/glib-2.0 \
C:/ ... /GTK/include/gtk-2.0 \
C:/ ... /GTK/include
LIBS += -LC:/ ... /GTK/lib -LC:/ ... /GStreamer/v0.10.6/sdk/lib -lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgtk-win32-2.0 -lgstinterfaces-0.10
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.
I am not a C++ master (far from that actually), I try to setup an OpenCV + Qt project. I have downloaded the last release of OpenCV. I did nothing more with that (if I understand well, everything is pre-built, so I just have to add the path to the libs in my .pro file).
I added the path to the include folder /opencv/include
That should work that way, since the includes in cv.h, for example, are like that :
include "opencv2/core/core_c.h"
However, when I browse through my opencv folder, opencv2 is empty, there is no core folder in it, nor anything else, actually there is just a header file, opencv.h .
I noticed that all my include are spread into several folders, under the module folder... what should I do??
Thank you very much!
You have to add those libraries in .pro file module wise, means you have to add all modules you are using in the project to LIBS variable in .pro file. Say if you are using modules libopencv1, libopencv2, libopencv3
LIBS += -L/usr/lib -lopencv1 -lopencv2 -lopencv3
like that.
If opencv libraries are added to /usr/local/lib, use -L/usr/local/lib instead of -L/usr/lib
Here is my .pro file :
QT += core gui
TARGET = test_MTI880
TEMPLATE = app
SOURCES += ... ... ...
INCLUDEPATH += D:/PointGreyResearch/FlyCapture2/include \
+= D:/opencv/include
LIBS += D:/opencv/build/x86/vc10/lib/opencv_core240.lib \
D:/opencv/build/x86/vc10/lib/opencv_highgui240.lib \
D:/opencv/build/x86/vc10/lib/opencv_imgproc240.lib \
D:/opencv/build/x86/vc10/lib/opencv_objdetect240.lib \
D:/PointGreyResearch/FlyCapture2/lib/FlyCapture2.lib \
D:/PointGreyResearch/FlyCapture2/lib/C/FlyCapture2_C.lib \
D:/PointGreyResearch/FlyCapture2/lib/FlyCapture2d.lib \
D:/PointGreyResearch/FlyCapture2/lib/FC1/PGRFlyCapture.lib
OK I found the answer...
The right include folder is the one into the build folder ... -_-'
I am having a problem with running an example from qt which uses win32 libraries. When I compile I don't get any errors but when I run it is not able to open the application (.exe) file in Windows 7. But when I compile this example in WindowsXP it works fine. Can anyone let me know whether I need to change my .pro file in order to get it worked under Windows 7?
Here is my .pro file:
# -------------------------------------------------
# Project created by QtCreator 2010-04-16T11:45:43
# -------------------------------------------------
QT += network
QT += xml
QT += opengl
TARGET = Application
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp \
Tools.cpp \
Objects.cpp
HEADERS += mainwindow.h \
Tools.h\
Objects.h
unix {
OBJECTS_DIR = .obj
MOC_DIR = .moc
}
# UNIX installation
isEmpty(PREFIX):PREFIX = /usr/local
unix {
headers.path = $$PREFIX/include/ZIP
headers.files = $$HEADERS
target.path = $$PREFIX/lib
INSTALLS += headers \
target
}
!mac:x11:LIBS += -ldns_sd
win32:LIBS += -ldnssd
LIBPATH = C:/Temp/mDNSResponder-107.6/mDNSWindows/DLL/Debug
INCLUDEPATH += c:/Temp/mDNSResponder-107.6/mDNSShared
You can use Dependency Walker to help you find out what Qt DLLs are needed and copy them to the same folder as the .exe.
Your problem is probably because Windows can't find the Qt libraries.
Try placing the required Qt libraries (for instance QtNetwork4.dll, etc...) in the same directory as your .exe and see if it works.