Can't use Magick++ under Windows with Code::Blocks

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
kikill
Posts: 2
Joined: 2017-05-08T06:20:54-07:00
Authentication code: 1151

Can't use Magick++ under Windows with Code::Blocks

Post by kikill » 2017-05-08T06:39:48-07:00

Good morning everyone,

I'm new on c++ and I would like to use magick++ to make some tricks with images.
I read a lot of thing on internet but I can't figure out how to use magick++.

I saw a lot of thing about the folder Magick++_demo and the button.cpp file. So that's what I did :

I open Code::Blocks and I import a visual workspace and I select Magick++_Demo.dsw, I select the Gnu gcc compiler and here after importing all the files, I get a first error : "Fail to import *any* projects from workspace file. Well, why not ? Maybe there is no project file, only a workspace, all the files are imported.

I try to compile the button.cpp and I get an error about Magick++.h : No such file or directory.
After reading a lot of thing, I figured out that I needed to link the library. So that's what I did :
Project > Build options > Select Button > Search Directories > Compiler > C:\Program Files\ImageMagick-7.0.5-Q16\include
So, all the input file are linked
Project > Build options > Select Button > Search Directories > Link > C:\Program Files\ImageMagick-7.0.5-Q16\lib
So, all the lib are linked
Project > Build options > Select Button > Linker Settings :
I add the three libraries : CORE_RL_Magick++_.lib CORE_RL_MagickCore_.lib CORE_RL_MagickWand_.lib

So now, he found Magick++.h ! That's good right ? :) But nop, it still not working and that's why I'm there. I search like all the day why this shitty thing happen and I saw that I'm not the only one who faces this problem. But I never saw a solution for this problem. I get errors about undefined reference !

Code: Select all

||=== Build: default in button (compiler: GNU GCC Compiler) ===|
.objs\button.o:button.cpp|| undefined reference to `Magick::InitializeMagick(char const*)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::Color(char const*)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::Image()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::Geometry(std::string const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::size(Magick::Geometry const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::~Geometry()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::read(std::string const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::Image(std::string const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::texture(Magick::Image const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::Color(std::string const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::fillColor(Magick::Color const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::~Color()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::fontPointsize(double)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::annotate(std::string const&, MagickCore::GravityType)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::borderColor(Magick::Color const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::Geometry(char const*)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::frame(Magick::Geometry const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::~Geometry()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::depth(unsigned int)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::quantizeDither(bool)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::quantizeColors(unsigned int)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::quantize(bool)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::compressType(MagickCore::CompressionType)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::write(std::string const&)'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::~Image()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::~Image()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::~Color()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::~Geometry()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::~Color()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Geometry::~Geometry()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::~Image()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Image::~Image()'|
.objs\button.o:button.cpp|| undefined reference to `Magick::Color::~Color()'|
||error: ld returned 1 exit status|
||=== Build failed: 34 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
If someone know how to fix these undefined reference.
I saw that solution on the net but I don't know how to use it :
g++ `Magick++-config --cxxflags --cppflags` -o CmdLineClient CmdLineClient.cpp `Magick++-config --ldflags --libs`

where can I write this command compiler (I think it's a command to build the project) on Code::Blocks ?

Thank's in advance guys !

snibgo
Posts: 9379
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't use Magick++ under Windows with Code::Blocks

Post by snibgo » 2017-05-08T07:18:25-07:00

I don't use Code::Blocks and don't know the answer.

"undefined reference" means the program compiled but couldn't link. So you are not linking against the correct libraries.

You can see that the suggested compilation command includes...

Code: Select all

Magick++-config --ldflags --libs
... as a back-ticked subcommand. I don't know how you would tell Code::Blocks to include that. The Code::Blocks documentation may tell you.

You can run that command and see what libraries are needed, and then include those in your project.
snibgo's IM pages: im.snibgo.com

kikill
Posts: 2
Joined: 2017-05-08T06:20:54-07:00
Authentication code: 1151

Re: Can't use Magick++ under Windows with Code::Blocks

Post by kikill » 2017-05-12T04:42:35-07:00

As I said I link the library. I search where to put that command but I didn't find any way to use it on Code::Blocks so, I try to put it on different places but nothing happened.

Did someone use code::blocks here ?

Post Reply