Using gtkmm with Eclipse CDT

I'm trying to compile gtkmm. A simple example using Eclipse CDT, but for some reason it does not work.

I am compiling this on Mandriva Linux and GCC 4.4.3

I get this error, which I think is a communication error:

Building target: Test Invoking: GCC C++ Linker g++ -L/usr/include/gtkmm-2.4 -o"Test" ./test.o ./test.o: In function `main': test.cpp:(.text+0x39): undefined reference to `Gtk::Main::Main(int&, char**&, bool)' test.cpp:(.text+0x43): undefined reference to `Gtk::Window::Window(Gtk::WindowType)' test.cpp:(.text+0x4b): undefined reference to `Gtk::Main::run(Gtk::Window&)' test.cpp:(.text+0x53): undefined reference to `Gtk::Window::~Window()' test.cpp:(.text+0x5b): undefined reference to `Gtk::Main::~Main()' test.cpp:(.text+0x82): undefined reference to `Gtk::Main::~Main()' test.cpp:(.text+0x95): undefined reference to `Gtk::Window::~Window()' ./test.o: In function `global constructors keyed to main': test.cpp:(.text+0xaf): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0xbe): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0xd2): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0xe1): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0xf5): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0x104): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0x118): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0x127): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0x13b): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0x14a): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0x15e): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0x16d): undefined reference to `Glib::ustring::~ustring()' test.cpp:(.text+0x181): undefined reference to `Glib::ustring::ustring(char const*)' test.cpp:(.text+0x190): undefined reference to `Glib::ustring::~ustring()' collect2: ld returned 1 exit status make: *** [Test] Error 1 

Sorry for the long error log, but I don't know how to make it shorter

+4
source share
2 answers

Property Project-> C / C ++ Build-> Settings GCC C ++ Compiler -> Miscellaneous, add this line: pkg-config gtkmm-3.0 --cflags --libs to other flags. GCC C ++ Linker-> Miscellaneous, add this line: pkg-config gtkmm-3.0 --cflags --libs in the linker flags. If you are using gtkmm 2.4, just replace "gtkmm-3.0" with "gtkmm-2.4"

Mark the line GCC C ++ COMPILER VERBOSE (_V).

+4
source

You must add the whole library specified when pkg-config gtkmm-2.4 --cflags --libs in the terminal for Eclipse. As I understand it, Eclipse does not play well with pkg-config, so you need to add them manually.

Right click on your project> Properties> C / C ++ Build> Settings

In the GCC C ++ compiler in the directories, add each directory specified when pkg-config gtkmm-2.4 --cflags (directories only, drop -I and -pthread)

In GCC C ++ Linker in libraries add everything: pkg-config --libs (again, just add libraries, leave -l and -pthread)

+1
source

Source: https://habr.com/ru/post/1339197/


All Articles