1

I am creating a Qt widget with a backend representation I wrote separately. The backend uses Magick++, and I can get it to compile from the command line:

g++ -c ../SpriteCreator/WriteGIF.cpp sprite.cpp -I ../SpriteCreator/ Magick++-config --cxxflags --cppflags Magick++-config --ldflags --libs -O2

but when I try to compile the project Qt Creator it tells me

/home/tpope/obeyYourThirst/qtSpriteEditor/backend/sprite.cpp:15: error: Magick++.h: No such file or directory #include < Magick++.h>

I added the path for Magick++.h to the INCLUDEPATH, but now it has an error similar to this:

/home/tpope/obeyYourThirst/qtSpriteEditor/backend/sprite.cpp:66: error: undefined reference to `Magick::InitializeMagick(char const*)'

for every use of a Magick function. It seems to be not including the library. How do I do that in Qt Creator?

4
  • You need to put the Magick++-config stuff inside $() like this... $(Magick++-config --cxxflags --cppflags --ldflags --libs) to actually execute them, Commented Nov 11, 2015 at 20:34
  • They were in backquotes in my makefile, but the markdown apparently removed those. It works in my makefile. How do I get Qt Creator to execute them? Commented Nov 11, 2015 at 21:50
  • As a temporary fix, run the Magick++-config... -- ... --ldflags --libs command I gave above in your Terminal, and copy and paste the output into your Qt Creator Makefile and see if that fixes it for now. Commented Nov 11, 2015 at 22:14
  • I just did that, and it worked. Thanks! I still wish I could get Qt Creator to simply run $(Magick++-config --cxxflags --cppflags --ldflags --libs) though. Commented Nov 11, 2015 at 22:37

1 Answer 1

1

Since the .pro files in Qt Creator is (as far as I can tell) used to generate a Makefile, we can use make's ability to run a program on the shell and save its output.

I have added:

QMAKE_CXXFLAGS += $(shell Magick++-config --cppflags --cxxflags)

and

LIBS += $(shell Magick++-config --ldflags --libs)

to my .pro file, and I was able to add:

#include <Magick++.h>

to my program without a compile error, then compile a simple example (Just put out an animated .gif with a couple of colored pixels)

This obviously makes things like cross-compiling a little tricky (I don't know how to reference foreign libraries), but that's a problem for another time.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.