linking against multiple *mm libraries



Hi everyone,

I am trying to build a modified example from libpanelappletmm, and I
get some strange linking errors. The example, which is a simple gnome
panel applet, is extended to include a derived class of
Gnome::Bonobo::Window.

The problem is that I cannot link against libpanelappletmm-2.6
libbonobouimm-2.0 and libnonobomm-2.0 at the same time.

To use Gnome::Panel::Applet it is necessary to use "pkg-config
--cflags libpanelappletmm-2.6" while compiling and "pkg-config --libs
libpanelappletmm-2.6" while linking.

To use Gnome::Bonobo::Window it is necessary to use "pkg-config
--cflags libbonobouimm-2.0" libbonobomm-2.0" while compiling and
"pkg-config --libs libbonobouimm-2.0" libbonobomm-2.0" while linking.

This would then translate into using the combined line of "pkg-config
--cflags libpanelappletmm-2.6 libbonobouimm-2.0 libbonobomm-2.0" for
compiling and "pkg-config --libs libpanelappletmm-2.6
libbonobouimm-2.0 libbonobomm-2.0" while linking.

But during the compiling/linking procedure I get the following errors
which area all related to the linking procedure:

> make clean
rm -f *.o
rm -f main
> make
g++ `pkg-config --cflags libpanelappletmm-2.6 libbonobouimm-2.0
libbonobomm-2.0` -c -g main.cc
g++ `pkg-config --libs libpanelappletmm-2.6 libbonobouimm-2.0
libbonobomm-2.0` -o main  main.o
main.o(.gnu.linkonce.r._ZTC8MyWindow0_N5Gnome6Bonobo6WindowE+0x154):/usr/include/c++/3.3/bits/sstream.tcc:203:
undefined reference to `non-virtual thunk [nv:-8] to
Gnome::Bonobo::Window::~Window [in-charge]()'
main.o(.gnu.linkonce.r._ZTC8MyWindow0_N5Gnome6Bonobo6WindowE+0x158):/usr/include/c++/3.3/bits/sstream.tcc:203:
undefined reference to `non-virtual thunk [nv:-8] to
Gnome::Bonobo::Window::~Window [in-charge deleting]()'
collect2: ld returned 1 exit status
make: *** [main] Error 1


Is there anyone on this mailing list who has experienced similar
problems, or someone who can explain to me what I am doing wrong?
I am using debian testing (sarge), with gcc 3.3.4 and the standard
versions of libpanelappletmm, libbonobouimm and libbonobomm for debian
testing. In dpkg they show up as versions 2.6.0, 1.3.7 and 1.3.8
respectively.

Thanks in advance
/john

The makefile used looks like this:

cc=g++
gnomeCCFlags = `pkg-config --cflags libpanelappletmm-2.6
libbonobouimm-2.0 libbonobomm-2.0`
gnomeLDFlags = `pkg-config --libs libpanelappletmm-2.6
libbonobouimm-2.0 libbonobomm-2.0`

main: main.o
	${cc} ${gnomeLDFlags} -o main  main.o

main.o : main.cc
	${cc} ${gnomeCCFlags} -c -g main.cc

clean:
	rm -f *.o
	rm -f main




And the code in question (main.cc):

/* main.cc
 *
 * Copyright (C) 2003 libpanelappletmm Development Team
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */


#include <libpanelappletmm.h>
#include <gtkmm.h>
#include <libbonobo.h>
#include <iostream>
#include <sstream>

#include <bonobomm/widgets/window.h>
#include <libbonoboui.h>

class MyWindow : public Gnome::Bonobo::Window
{
public:
  MyWindow(int test);
  virtual ~MyWindow();

private:
  int _myint;
};

class MyApplet : public Gnome::Panel::Applet
{
public:
  explicit MyApplet(PanelApplet* castitem);
  virtual ~MyApplet();
  
  void on_size_change(int size);
  void on_back_change(Gnome::Panel::AppletBackgroundType type, const
Gdk::Color & color, const Glib::RefPtr<const Gdk::Pixmap>& pixmap);

  static void size_diag(BonoboUIComponent *, void *applet, const gchar *);
  static void back_diag(BonoboUIComponent *, void *applet, const gchar *);
};

// ---------------- MyWindow ------------------------

MyWindow::MyWindow(int test) :
  Gnome::Bonobo::Window(),
  _myint(test)
{

}

MyWindow::~MyWindow() {
}

// ---------------- MyApplet ------------------------

MyApplet::MyApplet(PanelApplet* castitem)
: Gnome::Panel::Applet(castitem)
{
  static const Glib::ustring menu_xml = 
    "<popup name=\"button3\">\n"
    "   <menuitem name=\"Get Size Item\"\n"
    "             verb=\"SimpleGetSize\" _label=\"Get _Size...\"\n"
    "             pixtype=\"stock\" pixname=\"gtk-properties\"/>\n"
    "   <menuitem name=\"Get Background Item\"\n"
    "             verb=\"SimpleGetBack\" _label=\"Get _Background...\"\n"
    "             pixtype=\"stock\" pixname=\"gtk-properties\"/>\n"
    "</popup>\n";

  static const BonoboUIVerb menu_verbs[] = {
    BONOBO_UI_VERB("SimpleGetSize", &MyApplet::size_diag),
    BONOBO_UI_VERB("SimpleGetBack", &MyApplet::back_diag),
    BONOBO_UI_VERB_END
  };

  setup_menu(menu_xml, menu_verbs, this);
  add(*Gtk::manage(new Gtk::Label("Simple Applet")));
  signal_change_size().connect(sigc::mem_fun(*this, &MyApplet::on_size_change));
  signal_change_background().connect(sigc::mem_fun(*this,
&MyApplet::on_back_change));

  set_flags( Gnome::Panel::APPLET_EXPAND_MINOR );
  
  show_all();
}

MyApplet::~MyApplet()
{
}

void MyApplet::on_size_change(int size)
{
  Gtk::MessageDialog dialog("Changed size!");
  dialog.run();
}

void MyApplet::on_back_change(Gnome::Panel::AppletBackgroundType type,
const Gdk::Color & color, const Glib::RefPtr<const Gdk::Pixmap>&
pixmap)
{
  Gtk::MessageDialog dialog("Changed background!");
  dialog.run();
}

void MyApplet::size_diag(BonoboUIComponent *, void *applet, const gchar *)
{
  // applet is the c++ wrapped applet, so we have to cast it
  MyApplet *myapplet = static_cast<MyApplet*>(applet);
  std::ostringstream output;

  output.imbue(std::locale(""));
  output << "Applet size: " << myapplet->get_size();
  
  Gtk::MessageDialog dialog(Glib::locale_to_utf8(output.str()));
  dialog.run();
}

void MyApplet::back_diag(BonoboUIComponent *, void *applet, const gchar *)
{
  MyApplet* myapplet = static_cast<MyApplet*>(applet);

  std::ostringstream output;
  output.imbue(std::locale(""));

  Gdk::Color back_color;
  Glib::RefPtr<Gdk::Pixmap> back_pixmap;
  Gnome::Panel::AppletBackgroundType back_type =
myapplet->get_background(back_color, back_pixmap);

  {
    using namespace Gnome::Panel;
    switch(back_type)
    {
      case COLOR_BACKGROUND:
        output << "Panel uses a color.\nRed: " << back_color.get_red()
<< "\nGreen: " << back_color.get_green() << "\nBlue: " <<
back_color.get_blue();
        break;
      case PIXMAP_BACKGROUND:
        output << "Panel uses a pixmap background.";
        break;
      case NO_BACKGROUND:
      default:
        output << "Panel uses Gtk+ theme.";
        break;
    }
  }
  
  Gtk::MessageDialog dialog(Glib::locale_to_utf8(output.str()));
  dialog.run();
}

int main(int argc, char** argv)
{
  Gnome::Panel::init("TestPanelmm", "0.1", argc, argv);

  try
  {
    int returncode =
Gnome::Panel::factory_main<MyApplet>("OAFIID:SimplePA_Factory");

    return returncode;
  }
  catch(const Glib::Error& ex)
  {
    std::cout << ex.what() << std::endl;
    return 0;
  }
}



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