Archive

Archive for the ‘Open Source Software’ Category

LFS, pre-KDE: Errors Compiling qca-2.0.3

November 2nd, 2011 No comments

If you’re going through the Beyond Linux From Scratch guide, and run into this error while compiling qca-2.0.3 (and I assume many other versions of qca), I think I can help.

You don’t seem to have ‘make’ or ‘gmake’ in your PATH.
Cannot proceed.

The fix is relatively easy. Just make sure to have which installed on the machine. Jake found this out the hard way by looking through the configure script. Doing this experiment on Linux From Scratch has really given me an appreciation for distributions that come with basic utilities such as which.

Since which is very difficult to find on Google, here is a link: http://www.linuxfromscratch.org/blfs/view/svn/general/which.html


I am currently running ArchLinux (x86_64).
Check out my profile for more information.

How to enable reboot/shutdown in KDE on Gentoo

October 30th, 2011 No comments

Yeah… apparently the ability to restart or shutdown your system using a normal user account from within KDE SC is not something that is installed by default. In order to accomplish this you need to compile and install the kde-misc/kshutdown package using the following command from a root terminal:

emerge kde-misc/kshutdown

I also had to create a new file called /etc/portage/package.accept_keywords in order for this to work. Inside that file just put the following text

kde-misc/kshutdown-2.0




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: Gentoo, KDE, Tyler B Tags: , ,

Gentoo (A.K.A. “Compiling!”)

October 30th, 2011 No comments

For this version of the experiment I have chosen to try my hand at installing Gentoo. Gentoo, for those who don’t know, or who weren’t following Jake’s posts during the original experiment, is a fully customizable distribution where you have to compile and install all of your applications from source code downloads. Thankfully they do offer some excellent package management tools, Portage in particular, that help automate this process.

Preamble

I suppose a bit of background is the best place to start. During the original experiment I ran Fedora which, while having a whole host of issues of its own, was more or less a straight forward experience. Since that time I’ve dabbled here and there with other distributions, Ubuntu, openSUSE, Linux Mint, among others. For this experiment I wanted a bit of a challenge. I now know the basics, and then some, about running a day-to-day desktop Linux system but I still don’t fully understand all of the inner workings that are going on under the hood. That’s where my choice of Gentoo comes in.

Getting Started

I began by following the rather excellent Gentoo Handbook which thankfully got me to the point where I was able to boot my machine, without the installation media, into a kernel that I had personally configured and compiled. To say that this was smooth sailing probably isn’t accurate, but considering what was actually involved in getting to this point, and how quickly I managed to do it, is a testament to how easy the guide actually is to follow along with.

One thing I would stress to Linux users who may want to try Gentoo and are coming from a more user friendly distribution like Ubuntu is to make sure to get a list of hardware before you start. Run lshw in your Ubuntu (or whatever) install and save the output somewhere. This will show you the list of hardware devices and more importantly the drivers required to run them correctly. I ran into a snag early on where my network card wasn’t working even though Gentoo claimed to be loading the drivers correctly. A quick modprobe later of the driver that was shown to be in use from my earlier install, tg3, and I was back and Internet enabled. Sadly even the lshw output didn’t provide a whole lot of direction when it came to picking and choosing some of the more obscure configuration options for my kernel.

The Challenge

So what do you do when you can finally turn your computer on and boot into your kernel? Well install X I suppose. Unfortunately it was this step that caused me more grief than any of the others. You see apparently you’re supposed to remember what graphics card is in your machine before you try and build a kernel that supports it…

Following along with the X Server Configuration Guide I made it all the way up until the point when I had to specify which “in-kernel firmware blobs” I wanted to compile into my kernel. After, literally, hours of compiling X and then a series of trial and error attempts I finally found a combination that seemed to work. For my own reference the only firmware blob I seem to require is

radeon/R700_rlc.bin

The Wait

I finally had a system that could start X and present me with multiple(!) graphical terminals. By this point I had sunk about ~5 hours into this project. Now it was time to try setting up a desktop environment. My two main choices were GNOME 3.x or KDE SC. I opted for KDE for two reasons:

  1. I hadn’t used KDE 4.x in a couple of releases and didn’t mind it last time I had tried it
  2. I have yet to try GNOME 3.x but since it is quite the departure from the 2.x series I figured I would go with what I know for now and maybe try GNOME 3.x later

Pulling up the Gentoo KDE guide I began my compilation of KDE SC.

emerge -av kde-meta

More than 400 packages needed to be compiled and installed. My system, a Core2Duo at 2.4Ghz and 4GB of RAM, took approximately 24 hours to finish this single process. Gentoo is certainly not a system that you can expect to have up and running in an afternoon if you’re expecting to have a fully working desktop environment.

Miscellaneous

USE Flags are ridiculous. I understand the concept for them but the fact that you have to continuously add to this list in order to compile programs you explicitly told it to install is a bit much. If you don’t know what a USE Flag is consider yourself lucky. For those thinking about installing Gentoo, don’t worry you’ll know soon enough.

Be sure to change the root password and add any user accounts after you chroot into your new installation. Otherwise you’ll end up like me and boot into a system that you can’t log into!

Next Steps

Well I’d like to finish setting up my desktop. I now have KDE installed but there seems to be some missing components that I hope won’t require a re-compilation… I’ll let you know how that turns out. I also need to sort out my wireless card and get that working. But hey at least for now I can browse the web in my new installation!




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: Gentoo, KDE, Tyler B 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 zm1_1428.so[7f241ca01000+1000]
[ 2523.015245] lmms[10808]: segfault at 7fd80e9bcd80 ip 00007fd80e9bcd80 sp 00007fd80a9b7a38 error 14 in zm1_1428.so[7fd80ebc0000+1000]
[ 2671.323363] lmms[10845]: segfault at 7fbe39a77d80 ip 00007fbe39a77d80 sp 00007fbe35a72a38 error 14 in zm1_1428.so[7fbe39c7b000+1000]
[ 2836.885480] lmms[11246]: segfault at 7f885b71ed80 ip 00007f885b71ed80 sp 00007f8857719a38 error 14 in zm1_1428.so[7f885b922000+1000]
[ 3039.773287] lmms[11413]: segfault at 7ff83056ed80 ip 00007ff83056ed80 sp 00007ff82c569a38 error 14 in zm1_1428.so[7ff830772000+1000]

On the last few lines, you can see that the error was thrown in a module called zml_1428.so. 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.
jackd comes with ABSOLUTELY NO WARRANTY
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.

Create a GStreamer powered Java media player

March 14th, 2011 1 comment

For something to do I decided to see if I could create a very simple Java media player. After doing some research, and finding out that the Java Media Framework was no longer in development, I decided to settle on GStreamer to power my media player.

GStreamer for the uninitiated is a very powerful multimedia framework that offers both low-level pipeline building as well as high-level playback abstraction. What’s nice about GStreamer, besides being completely open source, is that it presents a unified API no matter what type of file it is playing. For instance if the user only has the free, high quality GStreamer codecs installed, referred to as the good plugins, then the API will only play those files. If however the user installs the other plugins as well, be it the bad or ugly sets, the API remains the same and thus you don’t need to update your code. Unfortunately being a C library this approach does have some drawbacks, notably the need to include the JNA jar as well as the system specific libraries. This approach can be considered similar to how SWT works.

Setup

Assuming that you already have a Java development environment, the first thing you’ll need is to install GStreamer. On Linux odds are you already have it, unless you are running a rather stripped down distro or don’t have many media players installed (both Rhythmbox and Banshee use GStreamer). If you don’t it should be pretty straight forward to install along with your choice of plugins. On Windows you’ll need to head over to ossbuild where they have downloadable installers.

The second thing you’ll need is gstreamer-java which you can grab over at their website here. You’ll need to download both gstreamer-java-1.4.jar and jna-3.2.4.jar. Both might contain some extra files that you probably don’t need and can prune out later if you’d like. Setup your development environment so that both of these jar files are in your build path.

Simple playback

GStreamer offers highly abstracted playback engines called PlayBins. This is what we will use to actually play our files. Here is a very simple code example that demonstrates how to actually make use of a PlayBin:

public static void main(String[] args) {
     args = Gst.init("MyMediaPlayer", args);

     Playbin playbin = new PlayBin("AudioPlayer");
     playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
     playbin.setInputFile("song.mp3");

     playbin.setState(State.PLAYING);
     Gst.main();
     playbin.setState(State.NULL);
}

So what does it all mean?

public static void main(String[] args) {
     args = Gst.init("MyMediaPlayer", args);

The above line takes the incoming command line arguments and passes them to the Gst.init function and returns a new set of arguments. If you have every done any GTK+ programming before this should be instantly recognizable to you. Essentially what GStreamer is doing is grabbing, and removing, any GStreamer specific arguments before your program will actually process them.

     Playbin playbin = new PlayBin("AudioPlayer");
     playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
     playbin.setInputFile("song.mp3");

The first line of code requests a standard “AudioPlayer” PlayBin. This PlayBin is built right into GStreamer and automatically sets up a default pipeline for you. Essentially this lets us avoid all of the low-level craziness that we would have to normally deal with if we were starting from scratch.

The next line sets the PlayBin’s VideoSink, think of sinks as output locations, to a “fakesink” or null sink. The reason we do this is because PlayBin’s can play both audio and video. For the purposes of this player we only want audio playback so we automatically redirect all video output to the “fakesink”.

The last line is pretty straight forward and just tells GStreamer what file to play.

     playbin.setState(State.PLAYING);
     Gst.main();
     playbin.setState(State.NULL);

Finally with the above lines of code we tell the PlayBin to actually start playing and then enter the GStreamer main loop. This loop continues for the duration. The last line is used to reset the PlayBin state and do some cleanup.

Bundle it with a quick GUI

To make it a little more friendly I wrote a very quick GUI to wrap all of the functionality with. The download links for that (binary only package), as well as the source (all package) is below. And there you have it: a very simple cross-platform media player that will playback pretty much anything you throw at it.

Please note that I have provided this software purely as a quick example. If you are really interested in developing a GStreamer powered Java application you would do yourself a favor by reading the official documentation.

Binary Only Package All Package
File name: my_media_player_binary.zip my_media_player_all.zip
Screenshots:
Version: March 13, 2011
File size: 1.5MB 1.51MB
File download: Download Here 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.

Recovering a Corrupted Banshee Database

February 27th, 2011 11 comments

A couple of nights ago, I left Banshee running overnight, filling my phone with music to listen to the next day at work. Sometime during that process, the media player crashed in a big way, and my entire system ground to a halt. When I woke up the next morning, my computer was frozen solid, with no keyboard or mouse input accepted, and the system clock hadn’t advanced since 11:16pm the previous night. I did a hard reboot, hoping that all would be well when it came back up.

Boy was I wrong.

The Problem

It seems that when Banshee went down, it took my library database file with it. Now, whenever I launch the application, I get a lovely dialog box that looks something like this:


Launching the application from the command line provides more details:

jonf@THE-LINUX-EXPERIMENT: ~/.config/banshee-1$ banshee-1
[Info  11:20:32.175] Running Banshee 1.9.0: [source-tarball (linux-gnu, x86_64) @ 2010-12-09 13:07:07 EST]
[Warn  11:20:32.451] Service `Banshee.Database.BansheeDbConnection’ not started: The database disk image is malformed
database disk image is malformed
[Warn  11:20:32.453] Caught an exception – Mono.Data.Sqlite.SqliteException: The database disk image is malformed

Apparently, the SQLite database that forms the backend of Banshee is severely corrupted, and the application can’t open it for reading. Based on the command line output, I figured that Banshee uses SQLite3 for its database, and after a little bit of research, I found out that it stores the database file at ~/.config/banshee-1/banshee.db. After installing the SQLite3 package from my repositories with the command sudo apt-get install sqlite3, I was able to connect to the database without issue. A little bit of reading over at sqlite.org showed me how to do an integrity check on the database, which came back with some nasty results:

jonf@THE-LINUX-EXPERIMENT:~/.config/banshee-1$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> PRAGMA integrity_check;
*** in database main ***
Main freelist: 2291 of 2292 pages missing from overflow list starting at 18928
On tree page 28 cell 4: Child page depth differs
On tree page 28 cell 6: 2nd reference to page 15475
On tree page 28 cell 6: Child page depth differs

On tree page 16807 cell 25: Child page depth differs
On tree page 16807 cell 26: 2nd reference to page 18171
On tree page 16807 cell 26: Child page depth differs

Each line of this output refers to a broken or corrupted index, with a total of 99 errors reported. Yikes.

The Solution

Before attempting to fix the problem, I made a backup of the broken database, just in case some data could be resurrected from it. To do this, I made sure that Banshee wasn’t running, and then made a copy of the database file with the command cp ~/.config/banshee-1/banshee.db ~/.config/banshee-1/banshee.db.old.

Since the integrity check showed a number of broken or corrupted indices, I thought perhaps I would be able to recover the database by rebuilding all of its indices. A quick scan of the SQLite documentation turned up the REINDEX function. Again, I connected to the database through the command-line interpreter, and gave it a shot:

jonf@THE-LINUX-EXPERIMENT:~/.config/banshee-1$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> REINDEX;
Error: database disk image is malformed

That clearly didn’t work.

My next thought was to drop and re-create all of the indices in the database, in hopes that I could rebuild them. I used the graphical tool sqliteman (available from your repositories with the command sudo apt-get install sqliteman) to dump the database schema out to a text file and then scrolled through the file looking for each index. I managed to drop all but four of them, but got the image malformed error whenever I tried to drop the remaining four or recreate any of the ones that were successfully dropped.

Out of ideas, I resorted to attempting to recover what data I could from the mangled file. Using sqliteman, I created a dump of my library data to go along with the schema dump that I had created earlier. The good thing about this dump is that it contains all of the data with none of the indices. Next, I opened up a terminal and navigated to the temporary directory where I had saved the database dump. Using the sqlite3 command line interpreter, I built an image of the old database from the dump:

jonf@THE-LINUX-EXPERIMENT:~/Desktop/banshee$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> .read dump.sql

Finally, I copied the newly created database into the banshee data directory with the command cp ~/Desktop/banshee/banshee.db  ~/.config/banshee-1/banshee.db.

The next time I started the application, all of my data was restored.

Prevention

I’ve put a lot of work into collecting and maintaining all of the music in my Banshee library. In order to avoid losing all of that work, I’ve decided to write a short script that takes a backup image of the library database every so often, and puts it in a safe place on my hard drive. Once I get that put together, I’ll throw it up on here for so that everybody can use 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

banshee-1

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-what?

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.

MainWindow.h

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
*/
-(void)destroyWidget;

/*
* Starts and hands off execution to the GTK main loop
*/
-(void)startGtkMainLoop;

/*
* Example Objective-C function that prints some output
*/
-(void)printSomething;

/*
********************************************************
* 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);

@end

MainWindow.m

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
gtk_widget_show_all(winMain);
}

//assign C-compatible pointer
myMainWindow = self;

//return pointer to this object
return self;
}

-(void)startGtkMainLoop
{
//start gtk loop
gtk_main();
}

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

-(void)destroyWidget{

myMainWindow = NULL;

if(GTK_IS_WIDGET (button))
{
//clean up the button
gtk_widget_destroy(button);
}

if(GTK_IS_WIDGET (winMain))
{
//clean up the main window
gtk_widget_destroy(winMain);
}
}

-(void)dealloc{
[self destroyWidget];

[super dealloc];
}

void on_MainWindow_destroy(GtkObject *object, gpointer user_data)
{
//exit the main loop
gtk_main_quit();
}

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];
}

@end

main.m

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: objective_c_gtk_source.zip
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.

Django Development on Ubuntu 10.04

December 8th, 2010 2 comments

When I’m not rocking out my ninja-like linux skillz here at The Linux Experiment, I like to spend my spare time working on SlightlySauced, a weekly round table podcast. When we started the show, we chose to host it on a simple Tumblr blog, because it offered a fast setup experience and didn’t require much additional configuration to work well enough for our purposes. In light of this week’s Tumblr outages, we’ve decided to move the show off of the cloud and onto the same hosting provider that this site resides on.

Since I find myself with a little bit of spare time recently, I’ve also decided to write a custom site for the show using Django, my new favourite web framework. If you’re interested in trying your hand at Django development (and honestly, if you’re doing web development of any kind, why haven’t you tried it yet?), you can follow along with my progress here.

Step 1: Installing MySql

Because Django is a Python-based web framework, it includes SQLite out of the box. My web host of choice provides solid MySQL support, so I’ve decided to swap out SQLite for MySql. This requires that I install a local MySQL server for development purposes. Ubuntu has posted some handy documentation that I followed loosely. I’ll repeat the relevant steps here for posterity and ease of use.

From your terminal, type:

sudo apt-get install mysql-server

During the installation process, you’ll be prompted to enter a password for MySql’s root user account. If your server is going to be public-facing, it’s a good idea to enter a strong password. If it’s just for development purposes, you can probably use something weaker and easier to type.

Once the installation has finished, check that your server is running by typing:

sudo netstat -tap | grep mysql

This command should output something like the following:

tcp     0     0     localhost:mysql     *:*     LISTEN 2556/mysqld

Note: This command didn’t actually work for me. I had to remove the pipe and type just

sudo netstat -tap

and then search the resulting list for the MySql entry. I found it easily enough, and was convinced that the daemon was running and waiting for clients.

Step 2: MySQL Workbench (Optional)

Once your MySql daemon is up and running, you could edit the /etc/mysql/my.cnf file to alter its configuration. Instead, I opted to use MySQL Workbench, a decent graphical management tool that is distributed by Oracle (the same folks who make MySql). I’ve used it extensively at work, so I’m familiar with it and comfortable with its quirks. If you care to use it, you’ll have to grab it from Oracle’s website, as it’s not in the Ubuntu repositories. Luckily, Oracle provides a Ubuntu 10.04 64-bit *.deb that can be easily installed with GDebi. For those who care about such things, MySQL Workbench is a fully OSS GPL-licensed product, so there’s no funny stuff going on with regards to licensing.

With MySQL Workbench up and running, you’ll be presented with a screen like this one:

Click on New Connection under the SQL Development column in the bottom left of the screen, and enter the connection details of your local MySql server. It should be available via the loopback IP 127.0.0.1 on port 3306. The default username is root, and the password is whatever you set during the installation process. Once you get access, you can create a new schema and fire a few commands at it to test your setup.

Head back over to the Home tab and click on New Server Instance under the Server Administration column at the bottom right of the screen. In the dialog that pops up, select Take Parameters from Existing Database Connection and hit Next a bunch of times. The resulting window is a full MySQL daemon monitoring window that details traffic, the number of connections to the server, etc. More importantly, it allows you to set up user accounts and change configuration variables from a handy graphical front end instead of wading through MySQL’s extensive configuration files.

I headed over to the Accounts tab and created a user account for Django. At this stage of development, you’ll want to give this account full root access to the database, as Django will automatically create and drop schemas and tables as you code your website. Once development is done, you can pare these down to only those that are necessary.

Step 3: Installing Django

Holy crap, that was a lot of work, and we haven’t even gotten our framework of choice installed yet! Let’s get on with that. The project has some excellent documentation on this issue. I’ll repeat the basic steps here for your convenience, but strongly suggest that you read through the full instruction set if you encounter any issues or want to perform a customized installation.

Since Django is a python-based framework, you’ll need to make sure that you have a compatible version of Python installed on your system. At the time of writing, Ubuntu 10.04 ships with Python version 2.6.5. Django only works with Python versions 2.4 through 2.7. If you’re not running Ubuntu 10.04, you can check which version you have installed by typing

python –version

in your terminal. Once you’ve ensured that you have a compatible Python version installed, type

sudo apt-get install python-django

in your terminal to install version 1.1.1 of the framework from your repositories. Once the installation has finished, you should check the installed version. Since Django lives inside of python, you’ll need to start a python terminal by typing

python

in your terminal. Once started, type

import django
print django.get_version()

If you don’t see any horrendous-looking error messages, you’re good to go. As a side note, if you type

apt-cache search django

you’ll see that the Ubuntu repositories include quite a few handy Django plugins and applications that you might want to use in your projects, including a URL shortener, a user-registration module, and a contact form. Each of these can be installed on your system and included in any Django project quite easily. I’ll probably end up using one or more in my project to save me some time.

Finally, you’ll need to install an extra database connector for python in order to use MySql from within Django. In Ubuntu 10.04, this package is called python-mysqldb.

Step 4: Write Some Code!

So you’re up and running. If you’re not familiar with Django, I suggest that you run through their online tutorial. It’s well-written and provides a great introduction to some of the stuff that the framework can do.

Whatever you do, have fun! In my experience, Django makes web development a pleasure because it takes care of a lot of the nitty-gritty crap for you and lets you get on with solving harder problems.

Let me know what you think in the comments.

Edit: Added an extra database connector package that’s necessary if you want to use MySql with Django.




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.

Samsung Captivate SGH-i896 Meets Linux

November 7th, 2010 2 comments

Yesterday, I picked up the newly launched (in Canada) Samsung Captivate. So far, I’m extremely impressed with the device. The super amoled display is gorgeous, the touch screen is responsive, and the UI is stunning to look at and use. Coming from a Blackberry Curve 8310, this phone is like a digital orgasm.

Once I finished gushing over how awesome this phone is, I decided to try and get it to interact with my Linux Mint 9 Isadora install. For now, I just want to be able to transfer images and music to and from the device, although later on, I’d like to get a development environment set up and try my hand at writing some apps.

My first try at getting the phone to play nicely with Linux was not successful. It took me a little bit of fooling around before I could figure it out, but here goes:

  • On the phone, navigate to Settings > Applications > USB Settings and make sure that ‘Ask on Connection’ is selected
  • Plug your phone into the a USB port, and when prompted, select ‘Mass Storage’ from the dialog that appears on the phone
  • At this point, if you open up your Computer in Nautilus, you should see an icon that says something like SAMSUNG SGH-I896, but you won’t be able to interact with it in any way
  • On the phone, grab the notification bar at the top of the home screen and drag it down
  • In the notifications area, tap USB Connected, and when prompted, select Mount from the dialog
  • Back in Nautilus, the icon under Computer should now say something like SAMSUNG SGH-I896: 14GB Filesystem, and you should be able to read and write to the card

With these steps complete, I was able to interact with the phone through the file system and from within Banshee and FSpot. I’m not sure why the phone won’t allow Linux to mount its storage devices by default when in Mass Storage mode, but this little work around seems to make it behave correctly.

Drop me a line in the comments if you have any Linux/Android compatibility questions, and I’ll do my best to help you out.




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.