[Solved] Compiling Program with External Classes

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
xc3ll

[Solved] Compiling Program with External Classes

Post by xc3ll »

So ImageMagick is working fine for me, but I can't figure out how to compile my program. I searched the forums and googled around, but I couldn't find anything. I probably didn't search for the right thing. Anyways, here's the details:

I have a class named minMax, I include it in my main file using #include "minMax.h"

I've compiled it using: $g++ -c minMax.cc

But when I try to link it to the program, I always get errors. Here's what I'm trying right now:

$ g++ main.cpp minMax.o `Magick++-config --cppflags --cxxflags --ldflags --libsls`

I've tried a lot of variation on this, but I can't get it to work. Anyone knows how to do this?

By the way, I've already successfully compiled other programs that don't include an external class.

Thanks!
Last edited by xc3ll on 2009-10-08T17:59:25-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compiling Program with External Classes

Post by magick »

This is the command we use to compile Magick++ source:
  • g++ `Magick++-config --cxxflags --cppflags` -o magick++ magick++.cpp `Magick++-config --ldflags --libs
xc3ll

Re: Compiling Program with External Classes

Post by xc3ll »

I've been able to successfully compile programs that use Magick++ functions. My particular problem is that I don't know how to include other external classes upon compilation. I need to include the class's .o file so I can access that class's functions within my code.

Just to be clear, I have three files:

Main.cpp <-- this is the main file, which uses Magick++ and minMax functions
minMax.cc & minMax.h <-- this is the external class, defining the private & public variables/func

Thank you
xc3ll

Re: Compiling Program with External Classes

Post by xc3ll »

Ok, I solved my problem. I swear I tried this before, but it worked. I must just be incredibly stupid.

This solved my problem:

g++ `Magick++-config --cxxflags --cppflags` -o Magick main.cpp minmax.cc `Magick++-config --ldflags --libs`
Post Reply