LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2007, 01:15 PM   #1
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Rep: Reputation: 16
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.
 
Old 04-16-2007, 10:06 AM   #2
dgard
LQ Newbie
 
Registered: Jan 2007
Posts: 7

Rep: Reputation: 0
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 ;-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Glade & Anjuta Build Problems! shawnrg Programming 1 07-02-2006 04:47 PM
glade python302 Linux - Software 3 04-15-2006 12:47 PM
How to use Glade? pratsadhu Programming 1 02-02-2006 12:13 PM
Glade 2.5.0 and Perl-Glade-Two - a little help please Lake-end Programming 1 03-07-2005 04:47 AM
glade anjuta C++ mover50 Linux - Software 0 11-11-2004 12:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration