How can I add Magick++ to Qt Creator - qt-creator

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.

Related

OpenCV libraries not found in Qt5 on OSX 10.10

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.

GStreamer Qt WINDOWS

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

Can't use C++11 features when building with Qt

I'm on OS X 10.8.4 (Mountain Lion) with the latest command line tools from Xcode. I'm trying to build a Qt project (in Qt Creator) which uses some C++11 features; notably std::unique_ptr. Whenever I try building though, I get the following error:
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
My .pro file is as follows:
QT += core gui
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++
LIBS += -mmacosx-version-min=10.7 -stdlib=libc++
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = APPNAME
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
cache()
I've tried the solutions presented in other answers (see here and the top answer here), neither of which seemed to work.
According to this site add
CONFIG += c++11
to your .pro file (see at the bottom of that web page). It requires Qt 5.
UPDATE: As for Qt 4, see How to enable C++11 in Qt Creator?

QtCreator and TBB under Windows

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.

Why can't g++ find/link to qjpeg4.dll?

Using Qt Creator 2.4.1 (Windows/mingw), I'm trying to compile my project dynamically linking with some Qt image plugins (i.e. the ones in C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\imageformats\). In the .pro file:
QTPLUGIN += qjpeg qgif qico qtiff
This is the error:
g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o release\myproject.exe object_script.myproject.Release -L"c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lmingw32 -lqtmain release\myproject_res.o -L. -lswscale-2 -lavcodec-54 -lavdevice-53 -lavfilter-2 -lavformat-54 -lavutil-51 -lusb -lPsapi -lasa047 -lsphinxbase -lpocketsphinx -LC:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins/imageformats -lqjpeg -lqgif -lqico -lqtiff -lQtMultimedia4 -lQtGui4 -lQtNetwork4 -lQtCore4
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lqjpeg
In the above you can see -LC:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins/imageformats specified before -lqjpeg and C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\imageformats\qjpeg4.dll exists ... so what gives?
Additional info: I can comment out the QTPLUGIN line in the .pro file and put instead:
LIBS += -LC:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\plugins\\imageformats -l:qjpeg4.dll
This links successfully, but I'm more interested in why QTPLUGIN appears broken out of the box under Windows mingw. What am I missing?
Seems to be a known (unresolved) bug with qmake: https://bugreports.qt.io/browse/QTBUG-24177?focusedCommentId=179693#comment-179693

Resources