Tuesday 1 November 2011

When libtool's dependency_libs goes weird

I had a strange problem last night where I couldn't build some code I was working on. The program (gpsim) depends on the Gtk stack and the errors I got seemed to refer to a nonexistant libtool .la file:

libtool: link: ar cru .libs/libgpsimgui.a gui_break.o gui_callbacks.o gui_dialog.o gui_init.o gui_main.o gui_menu.o gui_processor.o gui_regwin.o gui_src.o gui_src_asm.o gui_src_opcode.o gui_statusbar.o gui_symbols.o gui_watch.o gui_breadboard.o gui_stack.o gui_trace.o gui_profile.o gui_stopwatch.o gui_object.o gui_scope.o settings_exdbm.o gui_hextable.o preferences.o gui_marshal.o libtool: link: ranlib .libs/libgpsimgui.a /bin/sed: can't read /usr/lib/libgio-2.0.la: No such file or directory libtool: link: `/usr/lib/libgio-2.0.la' is not a valid libtool archive

Now, I'm running an up-to-date version of Debian unstable and I couldn't really believe that a problem that stopped people linking things depending on glib would survive very long. The solution came when I realised that references to /path/to/foo.la come from other .la files. Ahah! So, after some thought, I tried a grep command:

$ locate '*.la' | xargs grep libgio-2.0.la | grep '^/opt' | cut -d : -f 1
/opt/gnome/lib/gtk-2.0/modules/libgtkparasite.la
/opt/gnome/lib/libgpsim.la
/opt/gnome/lib/libgpsimcli.la
/opt/gnome/lib/libgpsimgui.la
/opt/gnome/lib/libgpsim_ds1307.la
/opt/gnome/lib/libgpsim_dspic.la
/opt/gnome/lib/libgpsim_graphicLCD.la
/opt/gnome/lib/libgpsim_lcd.la
/opt/gnome/lib/libgpsim_modules.la
/opt/gnome/lib/libgtkextra-x11-2.0.la

Ahah! The culprit was the last line: gpsim still links against the hideously obsolete libgtkextra and I'd forgotten to rebuild my local copy when upgrading my glib package to one that doesn't ship libgio-2.0.la. Editing the libgtkextra .la file might have worked but I just rebuilt the lot to make sure it worked. Sorted!

Tuesday 4 October 2011

Bookmarklet to ease the pain from Warwick Uni Library's E-journal change

The University of Warwick Library no longer allow access to E-journals except after jumping through hoops to access them through the library's web catalogue. This is painful and, although I've now got a plethora of links to various journal home-pages, I still find myself cutting and pasting parts of URLs to avoid some journals' awful navigation interfaces.

But all is not lost! Here's a JavaScript bookmarklet which will open up the current page channelled through Pugwash, which appears to be the library's main server. It seems to work for me, but the "0-" prefix on the URLs looks worryingly magical and I'm not sure whether this is correct for all journals...

To use the bookmarklet on Firefox (or pretty much anywhere else), you can right-click on the link (the "here" above) and select something like "Bookmark this link". If you are (rightly) wary of trusting a random hunk of JavaScript, this is the code:

javascript:(function(){
  var str=location.href;
  if(str.substr(0,7)!="http://") {
    alert("Unrecognised protocol");
    return;
  }
  var ffs=str.substr(7).indexOf("/");
  if(ffs==-1) {
    fs=str.length-1;
  }
  else {
    ffs=ffs+7;
  }
  window.open("http://0-" + str.substr(7,ffs-7) +
              ".pugwash.lib.warwick.ac.uk/"+str.substr(ffs+1));
})()

(It has to be on one line to work, so you'll need to delete a lot of whitespace if you want to copy and paste this).