ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I just started learning GTKmm (using Qt right now; just trying this toolkit out ;) ), and I ran into some problems. I tried to compile the example from gtkmm.org's tutorial, but apparently there is something going on with sigc++ 2.0. I'm using Mandrake 10.1 and installed all the appropriate libsigc++ libraries, including the development ones.
g++ complained that 'sigc' was undeclared, so I Googled around and found out that changing sigc to SigC should work, which it did. But now for some reason, the compiler complains that 'mem_fun' is not a member of SigC.
I'm just starting to use GTKmm a bit myself, but the code as you listed it should be the correct way to call sigc::mem_fun. Do you have the right headers included? Was the original error a compiler error or linker error? Perhaps you forgot to include the sigc library? Did you use pkg-config to get the cflags and libs?
I've got the sigc++ 2.0 library and I'm using a compile command similar to yours including the pkconfig bit. The original error was a compile error. This is the output from g++ after I attempt to compile a sample file:
Code:
g++ hello.cpp -o hello `pkg-config gtkmm-2.0 --cflags --libs`
hello.cpp: In function `int main(int, char**)':
hello.cpp:18: error: `sigc' has not been declared
hello.cpp:18: error: `mem_fun' undeclared (first use this function)
hello.cpp:18: error: (Each undeclared identifier is reported only once for each function it appears in.)
As for the headers, I'm not too sure which needs to be included, so I tried sigc++.h but that didn't seem to work. I also tried older versions of sigc++, such as 1.2, but that made no difference.
I get a different error when trying to compile your code:
Code:
$ g++ -o hello hello.cpp `pkg-config gtkmm-2.4 --cflags --libs`
hello.cpp: In function `int main(int, char**)':
hello.cpp:12: error: no matching function for call to `mem_fun(Gtk::Button&,
void (&)())'
The reason for the error is that sigc::mem_fun is meant to create a functor for class member functions, and you are trying to create a functor to a global function. Use the following instead:
Apparently, I upgraded to gtkmm-2.4 and that solved everything. I also changed mem_fun to ptr_fun like you said and that took care of the compile error. Thanks for all the help!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.