I am creating a GUI with C++. So I installed gtkmm using the terminal line:
sudo apt-get install libgtkmm-3.0-dev
and included gtkmm using #include <gtkmm.h>
. But when I followed a tutorial video and compiled my code:
g++ example.cpp -o out `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
I see an error:
In file included from example.cpp:1:0:
cross.hpp: In member function ‘void crossStd::gui_class::createWindow(int, int,std::__cxx11::string)’:
cross.hpp:95:9: error: ‘Gtk’ has not been declared
Gtk::Main kit(argc,argv);
^~~
cross.hpp:96:9: error: ‘Gtk’ has not been declared
Gtk::Window window;
I does not seem like it is linking gtkmm. What should I do to properly link gtk?
The appropriate include statement is:
#include <gtkmm/main.h>
That's according to the docs: https://developer.gnome.org/gtkmm/stable/classGtk_1_1Main.html
And you should always compile with -Wall
to enable warnings, which might have told you that your #include <gtkmm.h>
did not find any file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.