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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.