At the Hadrian Hotel

At the Hadrian Hotel

Tuesday, October 06, 2009

Running Simplify Media's Software on CentOS 5

I love Simplify Media's music sharing system. It lets me have access to all of the music I have on one computer from my iPhone or any other computer I use. So, I no longer need multiple copies of every song, and I can listen to the entirety of my collection from the iPhone, regardless of the amount of memory available on the phone. Now, I don't have a ton of music, but I do have over 30 GB. Clearly, that would be a bit tough to shoe-horn on to a 16 GB iPhone.

Now, in addition to the iPhone app, Simplify has software for the Mac, MS-Windows, and Ubuntu Linux. My home fileserver, where all of my music lives, is a Linux system, but for a number fo reasons I am running CentOS, not Ubuntu. Unfortunately, the Linux code provided by Simplify will not "just run" on CentOS because of a system library problem.

Simplify's Linux software includes the SimplifyMedia client and the SimplifyPeer server. These programs are dynamically linked and written in C++, and therefore require the libstdc++.so library. The latest library version available on CentOS is libstdc++.6.0.8, but the Simplify programs require libstdc++.so.6.0.9. I found all of this out when I tried to run SimplifyPeer and got this error message:
./SimplifyPeer: /usr/lib/libstdc++.so.6:version `GLIBCXX_3.4.9' not found (required by ./SimplifyPeer)
Being the geek that I am, I ran the 'strings' command against the library and looked for "GLIBCXX." The highest number I found was "3.4.8," which clearly was not going to cut it. I did a number fo different Google searches, and most of the results I found spoke of replacing the libstdc++.so file, but very few of them actually told me how to go about getting a copy. I finally stumbled across a forum post on eurocardsharing.com that included a link to download a RAR file containing the libstdc++.6.0.9 library file.

Great! Now I had the library file I needed to run the program. The problem I now had was that I was a bit nervous about replacing /usr/lib/libstdc++.so.6. I wasn't sure if just replacing it with a later version would break anything. So I started looking at options for the dynamic linker, starting with LD_LIBRARY_PATH. Unfortunately, none of the various permutations of LD_LIBRARY_PATH values I could think of worked. It was time to check out the ld.so man page....

In the ld.so/ld-linux.so man page on my system, the first environment variable listed is LD_LIBABRY_PATH, and the second one is LD_PRELOAD. Herein lies the required magic. Files listed in this variable are "ELF shared libraries to be loaded before all others." This allows you to "selectively override functions in other shared libraries." It turns out this was just what I needed.

The SimplifyPeer program is normally invoked by a bash script that sets a number of arguments in addition to those required from the user. Since I had unpacked the .tgz file into /usr/local, all I needed to do was put the libstdc++.so.6.0.9 file in the same directory as the program, and add this line to the bash script before the SimplifyPeer program was run:
export LD_PRELOAD=/usr/local/simplifymedia/libstdc++.so.6.0.9
That done, I fired up the simplifyserver.sh script with the appropriate arguments for my account, machine name and MP3 directory, and it ran! My family and I could now use Simplify Media to access all of the music on my fileserver from my laptop, the various PCs around the house and, most importantly, the short-on-memory iPhone. This will allow for more varied musical choices on those long car rides to DC when transporting my oldest to and from college.