Archive for the ‘Ubuntu’ Category

Ubuntu 12.10 Alpha 3 (Report #1)

August 27th, 2012 No comments

Well it’s been a little while since I made the mistake (joking) of installing Ubuntu 12.10 Alpha 3. Here is what I’ve learned so far.

  1. My laptop really does not like the open source ATI graphics driver – and there are no proprietary drivers for this release yet. It’s not that the driver doesn’t perform well enough graphically, its just that it causes my card to give off more heat than the proprietary driver. This in turn causes my laptop’s fan to run non-stop and drains my battery at a considerable rate.
  2. Ubuntu has changed the way they do updates in this release. Instead of the old Update Manager there is a new application (maybe just a re-skinning of the old) that is much more refined and really quite simple. Interestingly enough the old hardware drivers application is also now gone, instead it is merged into the update manager. Overall I’m neutral on both changes.

    Updates are quite frequent when running an alpha release

  3. There is a new Online Accounts application (part of the system settings) included in this release. This application seems to work like an extension of the GNOME keyring – saving passwords for your various online accounts (go figure). I haven’t really had a chance to play around with it too much yet but it seems to work well enough.

That’s it for now. I’m off to file a bug over this open source driver that is currently melting my computer. I’ll keep you posted on how that goes.

I am currently running a variety of distributions, primarily Linux Mint Debian Edition.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Categories: Tyler B, Ubuntu Tags: ,

Test driving the new Ubuntu (12.10)

August 26th, 2012 No comments

Call it crazy but I’ve decided to actually install an Ubuntu Alpha release, specifically Ubuntu 12.10 Alpha 3. Why would anyone in their right mind install an operating system that is bound to be full of bugs and likely destroy all of my data? My reasons are twofold:

  1. I regularly use Ubuntu or Ubuntu derivatives and would like to help in the process of making them better
  2. There are still a few quirks with my particular laptop that I would like to help iron out once and for all, hopefully correcting them in a more universal sense for Linux as a whole

So join me over the next few posts as I relate my most recent experiences running… shall we say, less than production code.


I am currently running a variety of distributions, primarily Linux Mint Debian Edition.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Categories: Tyler B, Ubuntu Tags: ,

Building glibc for LFS from Ubuntu by replacing awk

November 23rd, 2011 No comments

If you run into the following error trying to build LFS from a Ubuntu installation:

make[1]: *** No rule to make target `/mnt/lfs/sources/glibc-build/Versions.all', needed by `/mnt/lfs/sources/glibc-build/abi-versions.h'. Stop.

The mawk utility installed with Ubuntu, and symlinked to /usr/bin/awk by default does not properly handle the regular expressions in this package. Perform the following commands:

# apt-get install gawk
# rm -rf /usr/bin/{m}awk
# ln -snf /usr/bin/gawk /usr/bin/awk

Then you’re just a make clean; ./configure –obnoxious-dash-commands; make; make install away from success.

I am currently running various *BSD variants for this Experiment.
I currently run a mix of Windows, OS X and Linux systems for both work and personal use.
For Linux, I prefer Ubuntu LTS releases without Unity and still keep Windows 7 around for gaming.
Check out my profile for more information.

Ubuntu 11.10′s WiFi crashes my router

October 19th, 2011 9 comments

No seriously, it does. Whenever it makes a connection to the router it causes it to enter some bad state wherein it refuses to allow any connections to occur. This also has the effect of booting all other machines from the network. Apparently I’m not the only one to have this problem either.

I did manage to find a bit of a work around though:

  1. Set your wireless router to Mixed B/G mode only (yes I know, you lose out on N by doing this…)
  2. Enter the following into a terminal:
    echo "options iwlagn 11n_disable=1" | tee /etc/modprobe.d/iwlagn.confg
    sudo modprobe -rf iwlagn
    sudo modprobe -v iwlagn
    sudo service network-manager restart
  3. Maybe reboot?

I’ve also heard of some people getting it to work by enabling this instead of disabling it. To do so simply change the 11n_disable=1 line above to 11n_disable=0.

Hopefully they will have this annoying bug fixed soon.

I am currently running a variety of distributions, primarily Linux Mint Debian Edition.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Categories: Tyler B, Ubuntu Tags: , , , ,

How to install sun-java6-jdk and Netbeans in Ubuntu 11.10

October 14th, 2011 9 comments

If you’ve recently upgraded to Ubuntu 11.10 and are a developer you may notice some things missing. For one there is no longer an option to install the sun-java6-jdk or JRE from the repositories. Worse they also removed the Netbeans IDE. Apparently this had something to do with licenses but if you’re going to offer MP3 support the least you could do is make software like this available for those who are willing to look for it.

Anyway with that rant out of the way I did manage to find a way to install both.

Install sun-java6-jdk

Following the instructions on this excellent post I was able to successfully install sun-java6-jdk using the following commands:

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

There are alternative instructions for installing Java 7 as well.

Install Netbeans

My first attempt at installing both was to head to the official Oracle Java website and download the Netbeans + JDK installer. Unfortunately the installer seems to crash in this version of Ubuntu. However since the above process had installed the JRE I was able to simply grab the Netbeans only installer from Oracle which ended up working surprisingly well. Just remember to run it using sudo if you want other users to be able to use it as well.

I am currently running a variety of distributions, primarily Linux Mint Debian Edition.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Categories: Tyler B, Ubuntu Tags: , ,

On Veetle, Linux Mint, and ICEauthority

September 21st, 2011 4 comments

Like most people, I use my computer for multimedia. Recently I’ve discovered a multi-platform program called Veetle. It’s a pretty good program, but I ran into an issue after having installed it on my system (currently running Linux Mint 11): while I was using it to stream video, my computer basically locked up – every running process continued working, but I had no control over it. Since I was watching a full-screen video, this was pretty unfortunate. After all, it often helps to be able to maneuver your windows when you’re in a bind. I also immediately noticed that I lost all sound control on my keyboard. I rebooted my computer, but when I tried to log in, I got an error telling me that my computer could not update /home/user/.ICEauthority, followed by another error message, which I’m assuming was related but of less importance.

I actually into this exact problem before on an older machine, but before I had the chance to investigate, the hard disk died (for unrelated reasons). Luckily, I recognized the error on my newer machine and put two and two together: both failures coincided with the installation of Veetle. Now, because I’m a nerd, I have two functioning and constantly active computers right next to each other, for just such an occasion! It may also be related to the fact that websites that stream media tend to be a bit iffy so I feel more secure not using my Windows machine while exploring them, but enough about that! I Googled (or Binged, assuming “Bong” or “Bung” isn’t the past tense) a solution.

The solution

As it turns out, other people have run into this same problem, and it’s been covered on the Ubuntu forums and elsewhere. Basically, I ran the Veetle script as root (D’oh!), and this royally boned everything. This post by mjcritchie at the ubuntu Forums (which follows the advice of tommcd at explained what to do:

I have had the same problem twice, both times after updating (currently running 64bit Karmic).

Tried various solutions on the net, but this is the only one that worked for me:

Open a terminal and run:

sudo chown -R user:user /home/user/.*

Where user is your user_name. This should change ownership of all the hidden files and directories in your home directory to: user:user, as they should be.

This comes courtesy of tommcd over at this post on

So there you have it. My machine currently works, and now I can get back to streaming media. At least until the next time I get too adventurous when installing things.

Ubuntu 11.04 Installer Fail

August 24th, 2011 3 comments

So I decided to take a go at Ubuntu 11.04 in a virtual machine before taking the leap and installing it for real. As I understand it, the new Unity desktop is a pretty major departure from the Gnome 2.x desktop that I’m used to, and I want to see if it’s as bad as it looks in the screenshots.

Unfortunately, I’ve yet to make it to the desktop, as Ubuntu has decided that it will take 42 minutes to download some language packs that I neither want or need.

Didn’t I tell it what language I speak as the first step of the install process? Surely this can be done later.

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.
Categories: God Damnit Linux, Jon F, Ubuntu Tags:

Linux Multimedia Studio on Ubuntu 10.04

July 31st, 2011 1 comment

Recently, Tyler linked me to Linux Multimedia Studio, a Fruityloops-type application for Linux. Since I’m big into music recording and production, he figured that I’d be interested in trying it out, and he was right. Unfortunately, the developers of same were not as interested.

To start off, I installed the application from a PPA with the following terminal commands:

sudo apt-add-repository ppa:dns/sound
sudo aptitude update
sudo aptitude install lmms

After the install process finished, I tried to launch the application from the command line, only to see a bunch of nasty error messages:

jonf@THE-LINUX-EXPERIMENT:~$ sudo lmms
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
Segmentation fault

I dumped the errors into Google, and found a helpful thread on the Ubuntu forums that suggested that I uninstall Bluetooth Audio Services from my machine. Since I don’t use bluetooth audio in any capacity, I happily obliged. When finished, my list of installed items with Bluetooth in the name looked like this:

A list of installed software matching the search term "bluetooth" in Ubuntu Software Centre

Unfortunately, I didn't think ahead enough to note down the names of the packages that I uninstalled.

After ridding myself of Bluetooth audio support, I tried to launch the application again. Unfortunately, I got another Segmentation fault error:

jonf@THE-LINUX-EXPERIMENT:~$ sudo lmms
Segmentation fault

Reading on in the thread, I saw somebody suggest that I check the dmesg tail for messages pertaining to the crash:

jonf@THE-LINUX-EXPERIMENT:~$ dmesg | tail
[  233.302221] JFS: nTxBlock = 8192, nTxLock = 65536
[  233.314247] NTFS driver 2.1.29 [Flags: R/O MODULE].
[  233.343361] QNX4 filesystem 0.2.3 registered.
[  233.367738] Btrfs loaded
[ 2233.118020] __ratelimit: 33 callbacks suppressed
[ 2233.118026] lmms[10706]: segfault at 7f241c7fdd80 ip 00007f241c7fdd80 sp 00007f24187f8a38 error 14 in[7f241ca01000+1000]
[ 2523.015245] lmms[10808]: segfault at 7fd80e9bcd80 ip 00007fd80e9bcd80 sp 00007fd80a9b7a38 error 14 in[7fd80ebc0000+1000]
[ 2671.323363] lmms[10845]: segfault at 7fbe39a77d80 ip 00007fbe39a77d80 sp 00007fbe35a72a38 error 14 in[7fbe39c7b000+1000]
[ 2836.885480] lmms[11246]: segfault at 7f885b71ed80 ip 00007f885b71ed80 sp 00007f8857719a38 error 14 in[7f885b922000+1000]
[ 3039.773287] lmms[11413]: segfault at 7ff83056ed80 ip 00007ff83056ed80 sp 00007ff82c569a38 error 14 in[7ff830772000+1000]

On the last few lines, you can see that the error was thrown in a module called A bit of Googling turned up the fact that this module is a part of the LADSPA (Linux Audio Developers Simple Plugin API) stack, which provides developers with a standard, cross-platform API for dealing with audio filters and effects.

Scrolling down in the aforementioned thread, I found a post that suggested that I kill all PulseAudio activities on my system before attempting to run the application. PulseAudio is another part of the Linux audio layer that allows user-land applications to talk to your sound hardware via a simple API. It also provides some effects plugins and mixdown capabilities. I went ahead and killed the PulseAudio server on my machine with the following command:

jonf@THE-LINUX-EXPERIMENT:~$ killall pulseaudio

After executing this command, I still got a Segmentation fault when starting LMMS under my user account, but did actually get to a Settings panel when running it with Sudo:

jonf@THE-LINUX-EXPERIMENT:~$ sudo lmms
Home directory /home/jfritz not ours.
ALSA lib pcm_dmix.c:1010:(snd_pcm_dmix_open) unable to open slave
Playback open error: Device or resource busy
Expression 'snd_pcm_hw_params_set_buffer_size_near( self->pcm, hwParams, &bufSz )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1331
Expression 'PaAlsaStreamComponent_FinishConfigure( &self->playback, hwParamsPlayback, outParams, self->primeBuffers, realSr, outputLatency )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1889
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1994
Couldn't open PortAudio: Unanticipated host error
Home directory /home/jfritz not ours.
Home directory /home/jfritz not ours.

Although the output appeared to be riddled with audio layer errors, and the Audio Settings tab of the Setup panel gave me a clue as to why:

Notice how the Audio Interface setting in that image says “Pulse Audio (bad latency!)”. I would hazard a guess that the latency issues with PulseAudio have something to do with the fact that I killed it just prior to getting this damned thing to launch. When I hit the OK button, I was able to see the application, but there was no sound.

Figuring that sound was a necessary component of an audio production application, I booted back to the Setup menu, and told the app to funnel its audio through JACK instead of PulseAudio. The JACK Audio Connection Kit is another sound subsystem, kind of like PulseAudio, that provides an API that developers can use to interface with a machine’s audio hardware. Because of its low latency performance, JACK is often considered to be the standard API for high-quality audio recording and production apps. Unfortunately, it doesn’t work worth a damn in LMMS:

jonf@THE-LINUX-EXPERIMENT:~$ sudo lmms
jackd 0.118.0
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

no message buffer overruns
JACK compiled with System V SHM support.
loading driver ..
SSE2 detected
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
control device hw:0
SSE2 detected
all 32 bit float mono audio port buffers in use!
cannot assign buffer for port
cannot deliver port registration request
no more JACK-ports available!
No audio-driver working - falling back to dummy-audio-driver
You can render your songs and listen to the output files...
Home directory /home/jfritz not ours.
Home directory /home/jfritz not ours.
the playback device "hw:0" is already in use. Please stop the application using it and run JACK again
cannot load driver module alsa
Home directory /home/jfritz not ours.

Having dealt with JACK on a previous install, I had one more trick up my sleeve in my effort to get this bastard application to make a sound. I installed the JACK Control Panel from the Ubuntu Software Centre. It’s a QT app that interfaces with the JACK server and allows you to modify settings and stuff.

With it installed, I pressed the big green (or is it red – I’m colour blind, and hate when developers use these two colours for important status messages) Start button, only to encounter some nasty errors:

That might be a problem. I hit the messages button and found a message advising me to make a change to the /etc/security/limits.conf file so that JACK would be allowed to use realtime scheduling:

JACK is running in realtime mode, but you are not allowed to use realtime scheduling.
Please check your /etc/security/limits.conf for the following lines
and correct/add them:
@audio - rtprio 100
@audio - nice -10
After applying these changes, please re-login in order for them to take effect.
You don't appear to have a sane system configuration. It is very likely that you
encounter xruns. Please apply all the above mentioned changes and start jack again!

I figured that it was worth a shot, considering how far I’ve already gone just to try out a piece of software that I don’t really even need. I made the requested changes in the config file, restarted my machine and tried again… only to be greeted by the same damned error message.

At this point, I decided to give up on LMMS. It’s too damned complicated, and ultimately not worth my time. Perhaps when they release a version that I can install and start using without an hour of troubleshooting, I’ll come back and give it another shot. In the mean time, if you’re looking for a decent drum machine with more than a few tricks up its sleeve, check out Hydrogen Drum Machine. It works very well, and I’ve created some neat stuff in it.

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

How to Compile Banshee 1.9.0 on Ubuntu 10.04

December 9th, 2010 1 comment

Regular readers of this site will know that I’m no fan of Rhythmbox. When I recently installed Ubuntu 10.04 on my desktop PC, I decided to give Gnome’s default media player a few days to win back my affection. Unfortunately, while Novell’s Banshee project appears to be moving ahead with lots of great new features, Rythmbox still suffers from the issues that I outlined in my now infamous lambasting of it, nearly 8 months ago. To be fair, the pre-installed version of Rythmbox is only 0.12.8 on Ubuntu 10.04 (the same one that I reviewed previously), while the project has forged ahead to version 0.13.2.

Regardless, I prefer to listen to my music with Banshee, and I’m itching to try the latest version. On November 10th, the project released Banshee 1.9.0, and it looks positively excellent. I decided to give it a go, and downloaded the source tarball from the project’s website. Following are the steps that were necessary to install it:

  1. Head over to a terminal and install intltool, libgtk2.0-dev, libgtk2.0-cil-dev, libmono-dev, mono-gmcs, libmono-addins-cil-dev, monodoc-base, boo, libboo-cil-dev, libmono-addins-gui-cil-dev, libndesk-dbus-glib1.0-cil-dev, libgdata-dev, libgdata-cil-dev, libtag1-dev, libtaglib-cil-dev, sqlite3, libsqlite3-dev, libgconf2.0-cil-dev, libmtp-dev, libmono-zeroconf1.0-cil, libmono-zeroconf1.0-cil-dev, libwebkit-dev, libwebkit-cil-dev, and libsoup-gnome2.4-dev with the following command:

    sudo apt-get install intltool libgtk2.0-dev libgtk2.0-cil-dev libmono-dev mono-gmcs libmono-addins-cil-dev libmono-addins-gui-cil-dev monodoc-base boo libboo-cil-dev libndesk-dbus-glib1.0-cil-dev libgdata-dev libgdata-cil-dev libtag1-dev libtaglib-cil-dev sqlite3 libsqlite3-dev libgconf2.0-cil-dev libmtp-dev libmono-zeroconf1.0-cil libmono-zeroconf1.0-cil-dev libwebkit-dev libwebkit-cil-dev libsoup-gnome2.4-dev

  2. Next, you’ll need GStreamer and a few of its base plugins package: libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev

    sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

  3. If you want to play music encoded in non-free formats like mp3, you’ll also need a few restricted GStreamer libraries like gstreamer-plugins-good, gstreamer-plugins-bad, gstreamer-plugins-bad-multiverse, gstreamer-plugins-ugly, and gstreamer-plugins-ugly-multiverse.

    sudo apt-get install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-bad-multiverse gstreamer-plugins-ugly gstreamer-plugins-ugly-multiverse

  4. Since I don’t have an iPod or similar Apple device, I’ve configured my installation to disable Apple device support. If you have an iPod, you can lose the –disable-apple-device and –disable-ipod flags after the configure command, but you’ll also need to add a couple of extra libraries to your system. To compile and install Banshee, navigate to the folder where you unzipped the tarball, and type the following in your terminal:

    ./configure –disable-appledevice –disable-ipod
    sudo make
    sudo make install

Banshee should now be installed. From your terminal, type


as a sanity check. Once the application launches, select Help > About and ensure that the version number is 1.9.0. If so, you should be good to go.

I’ll try to post a full review of this latest version of Banshee within a couple of days. In the mean time, happy listening!

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Create a GTK+ application on Linux with Objective-C

December 8th, 2010 8 comments

As sort of follow-up-in-spirit to my older post I decided to share a really straight forward way to use Objective-C to build GTK+ applications.


Objective-C is an improvement to the iconic C programming language that remains backwards compatible while adding many new and interesting features. Chief among these additions is syntax for real objects (and thus object-oriented programming). Popularized by NeXT and eventually Apple, Objective-C is most commonly seen in development for Apple OSX and iOS based platforms. It ships with or without a large standard library (sometimes referred to as the Foundation Kit library) that makes it very easy for developers to quickly create fast and efficient programs. The result is a language that compiles down to binary, requires no virtual machines (just a runtime library), and achieves performance comparable to C and C++.

Marrying Objective-C with GTK+

Normally when writing a GTK+ application the language (or a library) will supply you with bindings that let you create GUIs in a way native to that language. So for instance in C++ you would create GTK+ objects, whereas in C you would create structures or ask functions for pointers back to the objects. Unfortunately while there used to exist a couple of different Objective-C bindings for GTK+, all of them are quite out of date. So instead we are going to rely on the fact that Objective-C is backwards compatible with C to get our program to work.

What you need to start

I’m going to assume that Ubuntu will be our operating system for development. To ensure that we have what we need to compile the programs, just install the following packages:

  1. gnustep-core-devel
  2. libgtk2.0-dev

As you can see from the list above we will be using GNUstep as our Objective-C library of choice.

Setting it all up

In order to make this work we will be creating two Objective-C classes, one that will house our GTK+ window and another that will actually start our program. I’m going to call my GTK+ object MainWindow and create the two necessary files: MainWindow.h and MainWindow.m. Finally I will create a main.m that will start the program and clean it up after it is done.

Let me apologize here for the poor code formatting; apparently WordPress likes to destroy whatever I try and do to make it better. If you want properly indented code please see the download link below.


In the MainWindow.h file put the following code:

#import <gtk/gtk.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>

//A pointer to this object (set on init) so C functions can call
//Objective-C functions
id myMainWindow;

* This class is responsible for initializing the GTK render loop
* as well as setting up the GUI for the user. It also handles all GTK
* callbacks for the winMain GtkWindow.
@interface MainWindow : NSObject
//The main GtkWindow
GtkWidget *winMain;
GtkWidget *button;

* Constructs the object and initializes GTK and the GUI for the
* application.
* *********************************************************************
* Input
* *********************************************************************
* argc (int *): A pointer to the arg count variable that was passed
* in at the application start. It will be returned
* with the count of the modified argv array.
* argv (char *[]): A pointer to the argument array that was passed in
* at the application start. It will be returned with
* the GTK arguments removed.
* *********************************************************************
* Returns
* *********************************************************************
* MainWindow (id): The constructed object or nil
* arc (int *): The modified input int as described above
* argv (char *[]): The modified input array modified as described above
-(id)initWithArgCount:(int *)argc andArgVals:(char *[])argv;

* Frees the Gtk widgets that we have control over

* Starts and hands off execution to the GTK main loop

* Example Objective-C function that prints some output

* C callback functions

* Called when the user closes the window
void on_MainWindow_destroy(GtkObject *object, gpointer user_data);

* Called when the user presses the button
void on_btnPushMe_clicked(GtkObject *object, gpointer user_data);



For the class’ actual code file fill it in as show below. This class will create a GTK+ window with a single button and will react to both the user pressing the button, and closing the window.

#import “MainWindow.h”

* For documentation see MainWindow.h

@implementation MainWindow

-(id)initWithArgCount:(int *)argc andArgVals:(char *[])argv
//call parent class’ init
if (self = [super init]) {

//setup the window
winMain = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_window_set_title (GTK_WINDOW (winMain), “Hello World”);
gtk_window_set_default_size(GTK_WINDOW(winMain), 230, 150);

//setup the button
button = gtk_button_new_with_label (“Push me!”);

gtk_container_add (GTK_CONTAINER (winMain), button);

//connect the signals
g_signal_connect (winMain, “destroy”, G_CALLBACK (on_MainWindow_destroy), NULL);
g_signal_connect (button, “clicked”, G_CALLBACK (on_btnPushMe_clicked), NULL);

//force show all

//assign C-compatible pointer
myMainWindow = self;

//return pointer to this object
return self;

//start gtk loop

NSLog(@”Printed from Objective-C’s NSLog function.”);
printf(“Also printed from standard printf function.\n”);


myMainWindow = NULL;

if(GTK_IS_WIDGET (button))
//clean up the button

if(GTK_IS_WIDGET (winMain))
//clean up the main window

[self destroyWidget];

[super dealloc];

void on_MainWindow_destroy(GtkObject *object, gpointer user_data)
//exit the main loop

void on_btnPushMe_clicked(GtkObject *object, gpointer user_data)
printf(“Button was clicked\n”);

//call Objective-C function from C function using global object pointer
[myMainWindow printSomething];



To finish I will write a main file and function that creates the MainWindow object and eventually cleans it up. Objective-C (1.0) does not support automatic garbage collection so it is important that we don’t forget to clean up after ourselves.

#import “MainWindow.h”
#import <Foundation/NSAutoreleasePool.h>

int main(int argc, char *argv[]) {

//create an AutoreleasePool
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

//init gtk engine
gtk_init(&argc, &argv);

//set up GUI
MainWindow *mainWindow = [[MainWindow alloc] initWithArgCount:&argc andArgVals:argv];

//begin the GTK loop
[mainWindow startGtkMainLoop];

//free the GUI
[mainWindow release];

//drain the pool
[pool release];

//exit application
return 0;

Compiling it all together

Use the following command to compile the program. This will automatically include all .m files in the current directory so be careful when and where you run this.

gcc `pkg-config –cflags –libs gtk+-2.0` -lgnustep-base -fconstant-string-class=NSConstantString -o “./myprogram” $(find . -name ‘*.m’) -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -std=c99 -O3

Once complete you will notice a new executable in the directory called myprogram. Start this program and you will see our GTK+ window in action.

If you run it from the command line you can see the output that we coded when the button is pushed.

Wrapping it up

There you have it. We now have a program that is written in Objective-C, using C’s native GTK+ ‘bindings’ for the GUI, that can call both regular C and Objective-C functions and code. In addition, thanks to the porting of both GTK+ and GNUstep to Windows, this same code will also produce a cross-platform application that works on both Mac OSX and Windows.

Source Code Downloads

Source Only Package
File name:
File hashes: Download Here
File size: 2.4KB
File download: Download Here

Originally posted on my personal website here.

I am currently running a variety of distributions, primarily Linux Mint Debian Edition.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.