Page 1 of 1

[Solved] Compiling Program with External Classes

Posted: 2009-10-06T18:19:37-07:00
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!

Re: Compiling Program with External Classes

Posted: 2009-10-07T05:46:48-07:00
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

Re: Compiling Program with External Classes

Posted: 2009-10-07T12:11:50-07:00
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

Re: Compiling Program with External Classes

Posted: 2009-10-08T17:59:09-07:00
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`