Hello World!

My name is Sérgio Bernardino (a.k.a. smpb), and I am a software engineer, hobbyist photographer, and all-around geek. I hail from Lisbon, Portugal. Feel free to save this information and at any time.

Digital footprint

This is my official home on the web, but quite often you'll find me in a lot of other places as well.

17th November 2011

Photo

focused writing

focused writing

Tagged: InstagramPhotography

16th November 2011

Post with 22 notes

Errors when Installing DBD::mysql on Mac OS X

For some reason, installing DBD::mysql on Mac OS X is the source of much grief. There are countless blog entries, forum posts, and Stack Overflow questions floating around about this very same issue.

Obviously, it was only a matter of time until I was afflicted by this and end up losing hours of valuable time trying to puzzle out the proper solution. But fortunately I got it working, so I’ll add what I’ve found to the countless bits of information already in the “pile”.

“Symbol not found”

I’m assuming you’re not using the system’s default Perl installation1, and that you’ve installed the default MySQL binaries for your architecture from dev.mysql.com. The issue manifested itself to me on Snow Leopard, but I’ve no reason to believe (so far) that in Lion the behaviour is any different.

With Perl and MySQL properly installed on the machine, you move onto installing DBD::mysql2. It should build fine and begin testing.

At this time, you might get errors similar to this:

Error: Can't load './blib/arch/auto/DBD/mysql/mysql.bundle'
  for module DBD::mysql:
    dlopen(./blib/arch/auto/DBD/mysql/mysql.bundle, 2):
      Symbol not found: _is_prefix

or it might vary slightly, showing you this:

Error: Can't find 'boot_DBD__mysql' symbol in
  ./blib/arch/auto/DBD/mysql/mysql.bundle

Now, this only happened to me when I tried to install the module manually (after the tests failed when loading the client library - more below)3. If this is your case, first and foremost, make sure you’re invoking the configuration command correctly.

This is WRONG:

perl Makefile.PL --libs="-lmysqlclient -L/usr/local/mysql/lib"  \
--cflags=-I/usr/local/mysql/include

This is RIGHT:

perl Makefile.PL --libs="-L/usr/local/mysql/lib -lmysqlclient" \
--cflags=-I/usr/local/mysql/include

Notice the subtle difference in the order of the parameters.

In these circumstances, the best idea is to collect the adequate values like so:

~/ $> mysql_config --libs      
-L/usr/local/mysql/lib -lmysqlclient   -lpthread

~/ $> mysql_config --cflags
-I/usr/local/mysql/include  -Os -g -fno-common -fno-strict-aliasing -arch x86_64

Copying the information from this source will guarantee that you’ll avoid mistakes like the one I did above.

“Library not loaded”

But even if you aren’t affected by the errors above, chances are that you’re being greeted with this particular message:

Error:
    Can't load './blib/arch/auto/DBD/mysql/mysql.bundle'
  for module DBD::mysql:
    dlopen(./blib/arch/auto/DBD/mysql/mysql.bundle, 2):
      Library not loaded: libmysqlclient.18.dylib

This means that the compiled bundle is looking for the client library in the wrong place. You can correct this by fixing the reference in the bundle itself with the command:

sudo install_name_tool -change libmysqlclient.18.dylib  \
/usr/local/mysql/lib/libmysqlclient.18.dylib  \
./blib/arch/auto/DBD/mysql/mysql.bundle

Or you can make sure it never happens again by always setting this variable in your environment:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/

All done!

With all this set in place, the installation of DBD::mysql is unlikely to give much more trouble, beyond failing the connectivity tests if you don’t have the MySQL server running as it expects you to be.

But that is a harmless issue.


  1. If you’re not working from a perlbrew setup, that’s your first mistake. 

  2. For this effect (and to make your life easier) installing Bundle::DBD::mysql from CPAN, is recommended. 

  3. Yes, by trying to dig myself out of a hole, I dug one deeper and nearly buried myself in it. 

Tagged: DBD::mysqlPerlMac OS X

14th November 2011

Link with 4 notes

List of Freely Available Programming Books

Incredibly comprehensive list of readily available books related with programming.

I find lists like these to be a double-edged sword. They are very useful, but one can harm himself with too much information, by quickly losing focus and the realization that actually doing something is as important (if not more) than just endlessly reading about how it is done.

Still, this one is a keeper, and definitely worth a browse.

Tagged: LinkStack OverflowFreeProgrammingBooks

8th November 2011

Post with 4 notes

Codebits::API

Codebits, the massive hackathon extravaganza organized by Portuguese tech company SAPO, has its fifth edition happening in only a few days and I couldn’t be more excited about it. This will be my third consecutive year attending, and given that it has been improving by leaps and bounds with each edition, I have high expectations for this year.

Codebits Bot

API Preamble

Since the machine began churning inexorably towards the event’s November date, I made a point personally on being a lot more (pro-)active in my participation. Beyond taking part in the pre-event shenanigans (the geek quiz is one example that I am a huge fan of), I began planning an adequate participation in the 48h programming/hacking competition. I am a software developer after all, but the amount of code I’ve written in past Codebits editions has been pitiful.

While musing on ideas to tackle at the event proper, I took time to lay some groundwork that might prove useful eventually. In particular, I decided to map the event’s API onto my weapon of choice: Perl.

Although I am unsure of how many Perl mongers will attend (or even intend to hack on some Perl code during) the event, I purposefully left the implementation available publicly in the off-chance that it might be useful to someone. You can find it here:

Networking

Undoubtedly, you will be able to find me there dabbling away at some of this, or similar, code. If you’re attending the event, and have any passing interest in Perl1, don’t hesitate to drop by for a chat.


  1. Or even if you don’t. It’s not really like there should be a prerequisite for some good conversation :-) 

Tagged: ProgrammingCodebitsPerl

4th November 2011

Photo reblogged from 3eanuts with 7,651 notes


  $self++;

$self++;

Source: 3eanuts

Original theme by nostrich