Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old August 18th, 2007   #1
punong_bisyonaryo
Way Too Much Ubuntu
 
punong_bisyonaryo's Avatar
 
Join Date: Aug 2006
Beans: 279
Ubuntu UNR
Compiling GTK in Linux

Good day!

I have some programming background and wanted to make "front ends" and other GUI apps for Linux, so I thought I'd download the GTK tutorial from GTK.org.

They make it sound so easy. The GTK tutorial should have a warning: Before you get into GTK programming, you need to be quite adept at installing things from source first.

I am currently installing a virtual machine where I can try again compiling GTK. The first time, I completely borked my Ubuntu, boxes displaying instead of letters.

Can anyone point me to a good "GTK installation for dummies" tutorial/page/link/whatever? I want to learn GTK programming to gain more knowledge on Linux, but I can't install GTK and start programming until I know more knowledge on Linux.

Thanks in advance!
punong_bisyonaryo is offline   Reply With Quote
Old August 18th, 2007   #2
kostkon
Chocolate-Covered Ubuntu Beans
 
kostkon's Avatar
 
Join Date: Apr 2005
Location: EU - UK
Beans: 2,269
Ubuntu 8.04 Hardy Heron
Send a message via ICQ to kostkon Send a message via MSN to kostkon Send a message via Yahoo to kostkon Send a message via Skype™ to kostkon
Re: Compiling GTK in Linux

Quote:
Originally Posted by punong_bisyonaryo View Post
Good day!

I have some programming background and wanted to make "front ends" and other GUI apps for Linux, so I thought I'd download the GTK tutorial from GTK.org.

They make it sound so easy. The GTK tutorial should have a warning: Before you get into GTK programming, you need to be quite adept at installing things from source first.

I am currently installing a virtual machine where I can try again compiling GTK. The first time, I completely borked my Ubuntu, boxes displaying instead of letters.

Can anyone point me to a good "GTK installation for dummies" tutorial/page/link/whatever? I want to learn GTK programming to gain more knowledge on Linux, but I can't install GTK and start programming until I know more knowledge on Linux.

Thanks in advance!


Compile GTK?

You can find it in Synaptic. Also, you don't need to program the GUI, just install Glade, it's a user interface builder.

By installing Glade, Synaptic will install the necessary GTK libraries for you.
kostkon is offline   Reply With Quote
Old August 18th, 2007   #3
Compyx
Way Too Much Ubuntu
 
Compyx's Avatar
 
Join Date: Mar 2006
Location: Eefde, The Netherlands
Beans: 282
Ubuntu Jaunty Jackalope (testing)
Re: Compiling GTK in Linux

There's no need to install Gtk+ from source, if I'm not mistaken, this command should install the library and its headers:
Code:
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
It has been quite a while since I installed my gtk libs, so there might be something missing.

Anyway, once you've installed the correct libraries and their headers, you want to make use of a Makefile to avoid retyping those nasty `pkg-config ...` lines each time you compile and link. Perhaps something like this:

Code:
# Generic Makefile for new Gtk+ 2.x projects

CC = gcc
LD = gcc
VPATH =

CFLAGS = -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
         -Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-prototypes \
         -Wmissing-declarations -Wredundant-decls -Wformat-nonliteral \
         -Wnested-externs -g -pedantic -ansi -O2 `pkg-config --cflags gtk+-2.0`

LDFLAGS = `pkg-config --libs gtk+-2.0`

PROG = 
OBJS = 

all : $(PROG)

%.o : %.c
        $(CC) $(CFLAGS) -c $< -o $@

$(PROG) : $(OBJS)
        $(LD) $(LDFLAGS) $(OBJS) -o $(PROG)

clean :
        $(RM) $(OBJS) $(PROG)
Fill in the line after PROG with the name of your binary and OBJS with the object files you want to create (including the '.o' suffix).

Hope this helps..
Compyx is offline   Reply With Quote
Old August 18th, 2007   #4
kostkon
Chocolate-Covered Ubuntu Beans
 
kostkon's Avatar
 
Join Date: Apr 2005
Location: EU - UK
Beans: 2,269
Ubuntu 8.04 Hardy Heron
Send a message via ICQ to kostkon Send a message via MSN to kostkon Send a message via Yahoo to kostkon Send a message via Skype™ to kostkon
Post Re: Compiling GTK in Linux

For many reasons it is better to use Glade to create the GUI of an application. Especially, if you have many persons working on your project, it's much easier to maintain and change the GUI. It saves the file as an XML file and then with libglade you can load it very easily.

It does not mean that you don't need to study the GTK tutorial. If you read it it will help you to understand how it works. Also, you will need to learn about GLib and GTK data types, GtkObjects, etc, that there are chances you will use in your code.
kostkon is offline   Reply With Quote
Old August 18th, 2007   #5
punong_bisyonaryo
Way Too Much Ubuntu
 
punong_bisyonaryo's Avatar
 
Join Date: Aug 2006
Beans: 279
Ubuntu UNR
Re: Compiling GTK in Linux

Wow! Thanks for all your tips! I didn't know it was this easy, especially in contrast to compiling those gtk libraries, with all their dependencies, and with no explanation which depends on what.

I'll be trying out the glade path first. Thanks compyx for the pkg-config tip, I'll keep that Makefile in my records.
punong_bisyonaryo is offline   Reply With Quote
Old August 18th, 2007   #6
kostkon
Chocolate-Covered Ubuntu Beans
 
kostkon's Avatar
 
Join Date: Apr 2005
Location: EU - UK
Beans: 2,269
Ubuntu 8.04 Hardy Heron
Send a message via ICQ to kostkon Send a message via MSN to kostkon Send a message via Yahoo to kostkon Send a message via Skype™ to kostkon
Re: Compiling GTK in Linux

Quote:
Originally Posted by punong_bisyonaryo View Post
Wow! Thanks for all your tips! I didn't know it was this easy, especially in contrast to compiling those gtk libraries, with all their dependencies, and with no explanation which depends on what.

I'll be trying out the glade path first. Thanks compyx for the pkg-config tip, I'll keep that Makefile in my records.
Just a tip: prefer to install the glade3 package, which is for the new version of Glade.
kostkon is offline   Reply With Quote
Old August 22nd, 2007   #7
punong_bisyonaryo
Way Too Much Ubuntu
 
punong_bisyonaryo's Avatar
 
Join Date: Aug 2006
Beans: 279
Ubuntu UNR
Re: Compiling GTK in Linux

I tried out glade3, it looks great! Haven't had a time to do much though, just explore the interface. I've read somewhere about Anjuta being able to use Glade for a complete ground-up programming solution. Can Anjuta use Glade3 as well or are there other ideas that integrate with Glade3?
punong_bisyonaryo is offline   Reply With Quote
Old August 24th, 2007   #8
kostkon
Chocolate-Covered Ubuntu Beans
 
kostkon's Avatar
 
Join Date: Apr 2005
Location: EU - UK
Beans: 2,269
Ubuntu 8.04 Hardy Heron
Send a message via ICQ to kostkon Send a message via MSN to kostkon Send a message via Yahoo to kostkon Send a message via Skype™ to kostkon
Post Re: Compiling GTK in Linux

Quote:
Originally Posted by punong_bisyonaryo View Post
I tried out glade3, it looks great! Haven't had a time to do much though, just explore the interface. I've read somewhere about Anjuta being able to use Glade for a complete ground-up programming solution. Can Anjuta use Glade3 as well or are there other ideas that integrate with Glade3?
Yes, indeed, Anjuta is a very good IDE and has Glade integrated in it. I recommend you to install it.

There is a new version, 2.20, which you can install easily. Go here at the downloads section of the Anjuta site and in the middle of the page you will find instructions how to add its repository to your software sources list.

This way you will get the new version, because the Ubuntu official repositories offer an older version. Also, if you add the repository, you will get automatic updates every time there is a new version

If you have any question regarding installing Anjuta, don't hesitate to ask here.
kostkon is offline   Reply With Quote
Old August 31st, 2007   #9
shan0027
First Cup of Ubuntu
 
Join Date: Aug 2007
Beans: 1
Post Re: No package 'gtk+-2.0' found Problem Plz help needed

Guys ,I am new to Linux
I am facing one problem while compiling one package..
When i give command ./configure which is not in root directory..
it gives below error..I m not sure what it makes to cause this..
==============================================
Searching for canlib...
Could not find Kvaser canlib header file. I looked for
/usr/include/canlib.h
but it does not seem to exist.

Searching for GTK... not found.
I tried to execute pkg-config gtk+-2.0
and got this response:

Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
===============================

I gave command locate pkg-config
It gives following data
====================
/var/lib/dpkg/info/pkg-config.list
/var/lib/dpkg/info/pkg-config.md5sums
/usr/bin/pkg-config
/usr/lib/ruby/1.8/pkg-config.rb
/usr/share/doc/pkg-config
/usr/share/doc/pkg-config/AUTHORS
/usr/share/doc/pkg-config/NEWS.gz
/usr/share/doc/pkg-config/README
/usr/share/doc/pkg-config/changelog.Debian.gz
/usr/share/doc/pkg-config/changelog.gz
/usr/share/doc/pkg-config/copyright
/usr/share/man/man1/pkg-config.1.gz
==================================
Please help me to resolve this problem..I am very beginner to Linux package ..I am experience programmer in Windows
shan0027 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:39 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry