1

I'm trying to compile following example

#include <gtkmm.h>

int main(int argc, char *argv[])
{
  Glib::RefPtr<Gtk::Application> app =
    Gtk::Application::create(argc, argv,
      "org.gtkmm.examples.base");

  Gtk::Window window;
  window.set_default_size(200, 200);

  return app->run(window);
}

i use this command: g++ ./gtk.cpp -o ./gtk -Wall pkg-config gtkmm-3.0 --cflags --libs and get this error message: /usr/local/lib/libatk-1.0.so: undefined reference to 'g_type_check_instance_is_fundamentally_a' collect2: error: ld returned 1 exit status how can i fix it ?

Tony
  • 5,797
  • 3
  • 26
  • 22

1 Answers1

1

Use this:

g++ ./gtk.cpp -o ./gtk -Wall `pkg-config gtkmm-3.0 --cflags --libs`

You need to add ` before and after pkg-config command.

pkg-config gives you flags for compiler and they have to be passed as compiler parameter (Output of pkg-config but not same pkg-config command).

Adding ` character cause pkg-config command output is added as parameter to compiler.

You can simply visualize this difference using echo:

$ echo pkg-config gtkmm-3.0 --cflags --libs
pkg-config gtkmm-3.0 --cflags --libs

$ echo `pkg-config gtkmm-3.0 --cflags --libs`
-pthread -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/atk-1.0 -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gio-unix-2.0/ -I/usr/include/atkmm-1.6 -I/usr/include/pangomm-1.4 -I/usr/lib/pangomm-1.4/include -I/usr/include/cairomm-1.0 -I/usr/lib/cairomm-1.0/include -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0
jmmk
  • 93
  • 1
  • 9
  • yes, i did that, i just didn't know how to escape them and insert into question – Tony Apr 19 '15 at 18:34
  • no it's not. i'm getting this error and have no idea why – Tony Apr 20 '15 at 03:05
  • make sure you have libatk installed in verson 1.0 *sudo apt-get install libatk1.0* – jmmk Apr 20 '15 at 08:13
  • What distro (and version) is this? – murrayc Apr 21 '15 at 08:02
  • @murrayc it's Mint 17.1 "Rebecca" - Cinnamon (32-bit) – Tony Apr 21 '15 at 14:20
  • Where is the library? Try to find it: *locate libatk-1.0* and then *sudo ln -f -s /usr/path_where_it_is_located /usr/local/lib/libatk-1.0.so* – jmmk Apr 21 '15 at 15:27
  • Tony, then this looks like a problem with the Mint package. I suggest that you try a simple GTK+ C hello world program too. – murrayc Apr 24 '15 at 12:40
  • @jmmk _locate libatk-1.0_ output : _/usr/lib/i386-linux-gnu/libatk-1.0.so_ _/usr/lib/i386-linux-gnu/libatk-1.0.so.0_ _/usr/lib/i386-linux-gnu/libatk-1.0.so.0.21009.1_ _/usr/local/lib/libatk-1.0.la_ _/usr/local/lib/libatk-1.0.so_ _/usr/local/lib/libatk-1.0.so.0_ _/usr/local/lib/libatk-1.0.so.0.21512.1_ – Tony Apr 25 '15 at 05:56
  • @murrayc compiling simple [GTK+ C example](https://developer.gnome.org/gtk3/stable/gtk-getting-started.html) give me the same error: _/usr/local/lib/libatk-1.0.so: undefined reference to `g_type_check_instance_is_fundamentally_a'_ – Tony Apr 25 '15 at 05:58
  • @Tony Then it looks like a problem with the GTK+ (or atk) package on Mint. I suggest that you report it to Mint. It does seem strange that such a fundamental package would be broken, but I guess the Mint packagers would be the best people to help with it. – murrayc Apr 25 '15 at 08:44