Reputation: 41
I'm trying to reproduce the example at - https://developer.gnome.org/gtkmm-tutorial/stable/sec-treeview-examples.html.en#treeview-dnd-example
Compile time error:
"make_managed" is not a member of 'Gtk' in the file treeview_withpopup.cc at the line auto item = Gtk::make_managed("_Edit", true);
The Netbeans IDE too shows an error at the same line
"Unable to resolve the identifier make_managed"
I've copied the code from the site and gtkmm.h is included in the header file.
I did not find any such question been asked on Stackoverflow yet! Why am I receiving this compile error?
Please help.
Upvotes: 4
Views: 1828
Reputation: 522
Just to compile the example given on the following page:
https://developer.gnome.org/gtkmm-tutorial/stable/sec-range-example.html.en
I have added the following code fragment (thanks @GAVD) into the top of examplewindow.cc
namespace Gtk
{
template<class T, class... T_Args>
auto make_managed(T_Args&&... args) -> T*
{
return manage(new T(std::forward<T_Args>(args)...));
}
}
and the example had been successfully compiled (no needs to modify standard files)
Upvotes: 0
Reputation: 2134
Gtk::make_managed
is defined in gtkmm-3.0/gtkmm/object.h
(see this link).
I already got the same error. Then I checked file object.h
but there is no make_managed
function. I don't know why. I just installed from rpm packge (I used the OS Fedora 23).
My solution:
I add code of make_managed
in /usr/include/gtkmm-3.0/gtkmm/object
:
template<class T, class... T_Args>
auto make_managed(T_Args&&... args) -> T* // Note: Edited to add return type here!
{
return manage(new T(std::forward<T_Args>(args)...));
}
Upvotes: 5
Reputation: 25
The answer provided by @GAVD and edited by @Ayxan is correct.
Place the object.h
file linked by the that answer in the directory with your source code.
Add an #include "object.h"
before the other #include \<gtkmm-whatevers\>
.
The make_managed
function should resolve. Make sure that you remove this temporary fix when an updated version of gtkmm is fixes the problem permanently.
Or follow your local procedures to update /usr/include/gtkmm-3.0/gtkmm/object.h
I found that I also had to add the compiler flag -std=c++14
or -std=gnu++14
because of the way the make_managed
function uses type auto. Adding the compiler flag changes the expected C++ language level from the default to the 2014 standard.
Upvotes: 1