LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Anjuta, Glade and C++ (https://www.linuxquestions.org/questions/programming-9/anjuta-glade-and-c-546255/)

[KIA]aze 04-15-2007 01:15 PM

Anjuta, Glade and C++
 
I am using Anjuta+Glade to create a GTK+ GUI.
However, I am having problems with C++ code.

What is the best way to create a program using C++ and GTK+?

Right now, what I am doing is that I create a "GTK 2.0 Project", say that I want to use "both C and C++" and then change the generated makefile by replacing CC=gcc by CC=g++.
That way I can put C++ code in the callbacks.c file.

It works, but I would prefer to do things correctly.
Is there a way to tell Anjuta to generate the makefile with CC=g++?

Or do I have to give up on the callbacks.c file when using GTK with C++?

I also tried creating a "gtkmm 2.0 project". But in that case, there is no callbacks.c file.
How do I proceed in this case?

Do you know any good tutorial for creating a gtkmm project with Anjuta?
I know about this one, but unfortunately it only deals with gtk projects having a callbacks.c file.

dgard 04-16-2007 10:06 AM

Quote:

Originally Posted by [KIA]aze
What is the best way to create a program using C++ and GTK+?

As you have tried, the best way is to use gtkmm, that is the set of classes to use GTK+ with C++.

Quote:

Originally Posted by [KIA]aze
Right now, what I am doing is that I create a "GTK 2.0 Project", say that I want to use "both C and C++" and then change the generated makefile by replacing CC=gcc by CC=g++.
That way I can put C++ code in the callbacks.c file.

It works, but I would prefer to do things correctly.
Is there a way to tell Anjuta to generate the makefile with CC=g++?

Or do I have to give up on the callbacks.c file when using GTK with C++?

I also tried creating a "gtkmm 2.0 project". But in that case, there is no callbacks.c file.

As you realize, this is a hack. It may work, but will probably make difficult porting your project to future versions of Anjuta. A somewhat cleaner "mixed" solution would be add your own C++ files (.cxx or .cpp are the most widely used file extensions). Anjuta will probably recognize the extensions, or maybe gcc will, so you should have no problems. Just remember a couple of things:
- Don't mix C and C++. Use separate files (.c extension for C, .cxx for C++).
- Remember you must add extern "C" to C function prototypes (in .h files) in order to call them from C++.

Quote:

Originally Posted by [KIA]aze
Do you know any good tutorial for creating a gtkmm project with Anjuta?
I know about this one, but unfortunately it only deals with gtk projects having a callbacks.c file.

Sorry, I cannot help with this. I would do this:
1. expend a little time with google
2. if 1 doesn't work, try to find IRC forums related to Anjuta, gtkmm or both
3. if 2 doesn't help, ask in some of the Anjuta or gtkmm mailing lists (look around in the project sites).

Happy coding ;-)


All times are GMT -5. The time now is 06:04 AM.