December 3, 2011

Pavel Mazniker Pavel Mazniker
Lab Rat
175 posts

Linking to external software system in Qt project ( libraries , dll on Windows ) GraphicsMagick

 

Hello.
Does anybody know how to link to GraphicsMagick / ImageMagick:

GraphicsMagick [graphicsmagick.org]

libraries on Windows in Qt project :

I’ve installed

GraphicsMagick-1.3-Q8-windows-dll.exe

and after installation there is a folder that contains multiple .dlls in it on Windows.

I need next includes will be recognized by mingw :

  1. #include <GraphicsMagick/Magick++/Image.h>
  2. #include <GraphicsMagick/Magick++/STL.h>

but after I try in .pro file to put next line:

  1. LIBS += -lMagick++ -lWand -lMagick

I’ve got next compilation problem ( mingw ):

  1. ..\main_control_1\/mainwindow.h:58:43: error: GraphicsMagick/Magick++/Image.h: No such file or directory
  2. ..\main_control_1\/mainwindow.h:59:41: error: GraphicsMagick/Magick++/STL.h: No such file or directory

On Linux I’ve succeed to link to the GraphicsMagick using pkgconfig.

I’ve looked through several sources such that:
Similar discussion at StackOverflow [stackoverflow.com]

and documentation/manuals but can’t find out / understand what rows to put to Qt .pro files so the project will compile on Windows ( compiling system is mingw ).

What lines to enter in .pro file so that the linker will find all needed GraphicsMagick/Image Magick headers and will compile ?

Thanks in advance.

7 replies

December 3, 2011

Volker Volker
Robot Herder
5428 posts

You have to add the paths to the include files and the libraries to your .pro file, as with any other external library.

December 6, 2011

Pavel Mazniker Pavel Mazniker
Lab Rat
175 posts

Hi.I hope it should be linked as usual , but now here the facts I get when :

after installing ImageMagick from Windows installer:

in .pro file I’ve added:

  1. INCLUDEPATH += C:\Program Files\ImageMagick-6.7.3-Q8\include \
  2.                C:\Program Files\ImageMagick-6.7.3-Q8\include\magick \
  3.                C:\Program Files\ImageMagick-6.7.3-Q8\include\Magick++ \
  4.                C:\Program Files\ImageMagick-6.7.3-Q8\include\wand
  5.  
  6. LIBS += C:\Program Files\ImageMagick-6.7.3-Q8\*.dll

and including in Qt project by providing pathes to headers : .h files :

  1. #include "C:\Program Files\ImageMagick-6.7.3-Q8\include\Magick++\Image.h"
  2. #include "C:\Program Files\ImageMagick-6.7.3-Q8\include\Magick++\STL.h"

but part of directories from pathes above to desired to be included headers can’t “be seen” ( can’t be found ) Magick++ for example.

Yet not solved. I need perhaps somebody reliable and understand very well in connecting externals software modules to Qt project that have time and willing to help then if he has patience and time and we begin to cooperate we should create Qt project that uses 2 – 3 large external software systems on Windows , one can get upon successfull completion experience and perhaps some fee from me ( unfortunatelly I have very limited budgets last time ). Thanks.

December 7, 2011

Volker Volker
Robot Herder
5428 posts

If you set INCLUDEPATH in the .pro, you do not need the full path in your own headers.

So, you just need to add

  1. #include <Magick++>

And you must not link against the DLLs, but against the corresponding stub libs:

  1. # check the path
  2. LIBS += -L"C:\Program Files\ImageMagick-6.7.3-Q8\libs"
  3.  
  4. # if you're on MinGW use this
  5. LIBS += -lGraphicsMagick++ -lGraphicsMagickWand -lGraphicsMagick
  6.  
  7. # or if you're on visual studio use this
  8. LIBS += -lCORE_RL_Magick++_ -lCORE_RL_Wand_ -lCORE_RL_Magick_

EDIT/PS:
If you have paths containing spaces, you need to enclose those in quotes!

  1. INCLUDEPATH += "C:\Program Files\ImageMagick-6.7.3-Q8\include"

January 23, 2012

wspilot wspilot
Ant Farmer
51 posts

Hi,
I am trying to port a linux Qt application to Widows, using mingw. The problem is with imagemagick libs. Have put the magick libs and headers (magick mingw version) in place. They are found by mingw (gcc), but I am getting many ‘undefined references’, caused by not finding image.cpp somewhere in the (mingw) msys system. I am not an mingw expert, but it’s clear that Qt is not using msys.
Maybe Qt should warn about using mingw. I have been googling and trying for days now and I see many mailings from people getting stuck here, and none of the solutions work.

January 23, 2012

Volker Volker
Robot Herder
5428 posts

Welcome to DevNet!

The actual error message would be helpful, as well as your settings for LIBS and INCLUDEPATH variables of your .pro file.

January 23, 2012

wspilot wspilot
Ant Farmer
51 posts

Thanks for the reply.
I’ll give you the data of the latest attempt.

  1. INCLUDEPATH += C:/QtSDK/mingw/ImageMagick-6.6.9/include/ImageMagick
  2. LIBS += C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagickCore.a C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagick++.a C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagickWand.a
  3. QMAKE_CXXFLAGS += -I../../include
  4. TARGET.EPOCSTACKSIZE = 64000000

I put the lib (magick mingw build) including .a .la etc in correct dirs.
Got errors about not finding Image.cpp on the path below.
So I created this dir: C:\msys\1.0\home\cristy\
and put the magick source tree in the there. Image.cpp is now found.
Few thousand errors:

  1. C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.9-2/Magick++/lib/Image.cpp:4281: undefined reference to `MagickCoreGenesis'
  2. C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.9-2/Magick++/lib/Image.cpp:4242: undefined reference to `GetExceptionInfo'
  3. C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.9-2/Magick++/lib/Image.cpp:4245: undefined reference to `SetImageRegistry'
  4. C:/QtSDK/mingw/ImageMagick-6.6.9/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.9-2/Magick++/lib/Image.cpp:4247: undefined reference to `DestroyExceptionInfo'
  5. ....

So, nothing wrong with Qt, but mingw is acting strange. If you google you’ll see that the same problems apply to other libraries as well.
r.
wim

[EDIT: code formatting, Volker]

January 24, 2012

Volker Volker
Robot Herder
5428 posts

Hm, strange. Seems to be much more an ImageMagick issue. I would advice to ask in a special forum over there to check out what actually needs to be linked (or change on installing etc.). The libs and include paths then can be easily adapted in the .pro file. Feel free to come back here if you need some advice on how to include the settings into the qmake project file.

 
  ‹‹ How to make a project that is done with QtQuick to a gui application?      No such slot error ››

You must log in to post a reply. Not a member yet? Register here!