Re: Mixing C++ with glade



Glitch wrote:
> 
> Silviu Minut wrote:
> 
> > I have a pan-tilt camera which I control through the serial port. I have a
> > C++ interface for sending commands to the camera, compiled as a library.
> >
> > I want to write a program with a gtk interface for this library. I would
> > certainly prefer to use glade to generate the gtk code, but I would have
> > to declare some C++ classes in main. The code generated by glade produces
> > config files and Makefiles with CC=gcc.
> >
> 
> uh, why not change the line in the Makefile that you list above to say
> CC=g++??????
This is the wrong approach. Never, ever change autoconf generated
Makefile.
 
> if u don't want to use gcc and use g++ instead that is the variable you
> change.
No, CC is supposed to be the c-compiler, CXX is the
Makefile-variable to be used for c++ compilers.
  
> > Is there any way to "fool" glade to use g++ instead of gcc (and then, of
> > course, make the appropriate changes to the code)?
> > I don't have glade--. Is there any way around installing glademm?

Yes, to outline one way:
* convert glade's main.c into a c++ file (e.g. copy main.c to
main.cc, and add appropriated extern "C" {} guards around the
#include lines of glade generated headers.) 
* edit src/Makefile.am to use main.cc instead of main.c and add
AM_PROG_CXX to the configure.in.
* Disable "Generate main.c" in glade's options.

A more sophisticated way is to put glade generated c-code into a
library and to link your c++-application against it.

Ralf
-- 
Ralf Corsepius 
Forschungsinstitut fuer Anwendungsorientierte Wissensverarbeitung
(FAW)
Helmholtzstr. 16, 89081 Ulm, Germany     Tel: +49/731/501-8690
mailto:corsepiu faw uni-ulm de           FAX: +49/731/501-999  
http://www.faw.uni-ulm.de




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]