Recently I had to port one of my projects (link) which so far was only targeting on Linux to Mac OS X. As an important part of the project are loadable C++ modules, I learned about an interesting difference between the two architectures.

Linux uses the ELF binary format for compiled programs and libraries, Mac OS X the Mach-O binary format. This has some consequences for the handling of modules respectively plug-ins. The ELF format does not distinguish between modules and shared libraries, once you compile your code you get output like libfoo.so. If you link with the libfoo library it is loaded on program start (if not already in memory), but you can also load the symbols from libfoo using dlopen.

This is not possible on Mac OS X. The MACH-O binary format used here distinguishes between modules and shared libraries (which usually have the suffix .dylib) . Shared libraries cannot be loaded dynamically as modules using dlopen, and they cannot be unloaded. Modules on the other hand (in Mac terminology they are called ‘bundles’) can be loaded and unloaded the same way as in Linux, but you cannot link against them. Using cmake the solution is to use

add_library(examplePlugin SHARED MODULE
  examplePlugin.cpp
)

in your CMakeLists.txt.

Share
 

Mute your notebook on suspend

On 2012/04/01, in Linux, by Tobias
0

Imagine sitting in a conference room – it is 5 minutes before the start of the first talk, so naturally some people are already there checking their emails. Like every time, you have the opportunity to listen to a concert made of a background from startup jingles and sporadic solos of different music and video clips from people who suspended their notebooks during playback the evening before. You can listen to the same concert for free in any library, train, café, and many more places.

While you can ignore this in some environments like a café or train, it becomes intolerable for example in a library or during a conference talk. This is (sadly) not only a problem resulting from Windows and Mac default settings. Some time ago someone from the Linux community decided that the major desktops should also honor these ridiculous default setting. I can imagine some reasons, why vendors of operating systems set a default startup jingle, you can probably immediately recall the default Windows or Mac sound! However, I cannot understand why people don’t turn them off.

Turning off the startup jingles is however only part of the problem, as people suspend their notebooks while videos or music are running, and the playback is resumed on startup. The solution is simple: mute the sound just before the notebook suspends. I have no idea why this is not the default behavior of any operating system. Nobody enjoys the moment you open your notebook in the library and it starts continuing yesterdays movie while you hastyly search for the mute button. So you have to apply a solution yourself to avoid these moments.

On a Linux system using the pm-utils you can execute scripts before the computer suspends (and after it wakes up and at many more occasions not discussed here. For a documentation see e.g. the arch Linux wiki). Here is the simple script I use to mute on suspend. It uses the amixer command line program (part of the alsa-utils package in Debian).

#!/bin/bash
case $1 in
        hibernate | suspend)
                su winchen -c "amixer sset Master mute"
                ;;

        thaw|resume)
                ;;
esac

The script has to be copied into the directory /etc/pm/sleep.d/ and made executable. It uses su to execute the amixer command as user, making the script only works in a single user setup – so far I didn’t need to investigate a solution for a multi-user setup, but any comments on that are very welcome.

Share
 

New Gallery

On 2012/03/24, in Photography, by Tobias
0
Pierre Auger Observatory

Pierre Auger Observatory

Images of the Pierre Auger Observatory in Malargüe, Argentinia. See http://www.auger.org for more informations. (24.03.2011, 3 Fotos)

Share
 

MoinDesktopBrowser

On 2011/01/28, in Stuff, by Tobias
0

I won’t continue developing MoinDesktopbrowser any further, as I started using zim as a digital notebook.

Share
 

Linux on a Thinkpad X201s

On 2010/12/21, in Linux, by Tobias
0

Originally I planned to post some informations about the installation of Debian GNU/Linux on my brand new Lenovo X201s notebook. Although I already knew the reputation of Thinkpads of being quite Linux friendly, I am still surprised that everything worked right out of the box. Not tested so far is the included modem (the typical software modem needing a Windows driver, so I don’t expect anything good …), but besides that there doesn’t seem to be a single issue:

  • Graphics and display works, together with composite
  • Wireless and Bluetooth (after installation of non-free firmware)
  • Suspend and hibernate
  • Dock with external VGA Monitor
  • Special keys (Volume, brightness, etc.)

work all right out of the box. My device has no camera, so this is also not tested.  So, having confirmed that the hardware is working,  I can now enjoy restoring my backups and playing around with this great device.

Share