Notes on making gtk-gnutella 0.93.3 stable build on OpenBSD 3.3

Original: January 27, 2004
Updated: January 31, 2004

Sections


Background

I hadn't used gnutella in awhile, and when I did I noticed that not only were there notices about a newer version but the newer clients were refusing to connect with gtk-gnutella-0.91.1. Of course I prefer to use official ports but that hasn't been updated at the time of this writing. Visitting the official gtk-gnutella homepage I see that: Some serious bugs have been found in 0.93.1 and 0.93.2. A feature freeze is in place and a bugfix 0.93.3 release is expected soon. And also the 0.93.3 stable source was available for download, so I went about trying to make that compile and install on my OpenBSD 3.3 patched system. When finished the program seems just fine and stable even, staying up overnight a couple times as a test.

Instructions

Now this isn't the proper fix and as such I've not created a patch. But it does get the source compiled and working on my system anyway. I'm outlining the steps in case it helps someone else to get the safer version of this software working on their system also. Note that the defaults during the ./Configure step result in the same warnings/errors on both OpenBSD 3.3 and 3.4 patch branch systems, and both systems build the software fine with the same workarounds that follow.

  1. Download the gtk-gnutella 0.93.3 stable source tarball (bzip'd).
  2. bunzip2 gtk-gnutella-0.93.3.tar.bz2
  3. tar -xvf gtk-gnutella-0.93.3.tar
  4. cd gtk-gnutella-0.93.3
  5. edit config_h.SH to remove warnings about BSD being redefined on every file being compiled.
  6. edit src/utf8.c, modifying line 666 so that char *inbuf is instead const char *inbuf. It should look like this when done:
    const char *inbuf, size_t inbytes_left,
  7. edit src/utf8.h, go to line 41 and add a new line. The new line 42 should look like this:
    #define CODESET 3
    Note that this results in using the US-ASCII charset, if that's not appropriate for your location see the notes below on how to find the right value for your desired character-set. Apparently I have abused the use of CODESET here, and simply got lucky that the code defaulted to my own charset, setting it to 3 isn't the way to go, will dig further when I get a chance.
  8. Next run ./Configure and accept any defaults except where changes are listed here:
  9. make
  10. sudo make install
  11. Done! To run it either setup an icon in your window manager or use the command line /usr/local/bin/gtk-gnutella if you like watching the warnings it generates.

Notes

After downloading and bunziping the source, these are the notes I took while making gtk-gnutella 0.93.3 stable build on an OpenBSD 3.3 patch-branch system. They're here mainly as notes to myself in making more straightforward instructions.

  1. tried both openbsd and OpenBSD in the Configure prompt but neither seemed to make a difference, I stuck with openbsd just in case....
  2. changed config.h:29 to duplicate the definition of BSD already defined in /usr/include/sys/param.h to remove the warning on each cc line.
  3. /usr/bin/mkdep not found by default, specify in Configure prompt
  4. Still this error persists:
    cc -c -I.. -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/X11R6/include -I/usr/local/include -O2 utf8.c
    utf8.c: In function `locale_charset':
    utf8.c:529: `CODESET' undeclared (first use in this function)
    utf8.c:529: (Each undeclared identifier is reported only once
    utf8.c:529: for each function it appears in.)
    utf8.c: In function `g_iconv_complete':
    utf8.c:680: warning: passing arg 2 of `libiconv' from incompatible pointer type
    *** Error code 1
    
    Stop in /home/anubis/gtk-gnutella-0.93.3/src.
    Making all in pixmaps...
    Making all in po...
    
    1. I've found that on this OpenBSD 3.3 system, libiconv 1.8 is installed. also, in /usr/local/include/iconv.h I find:
      extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
      
      so it seems the error above is a result of the char pointer not being const? so in src/utf8.c I change g_iconv_complete to:
      static inline char *g_iconv_complete(GIConv cd,
          const char *inbuf,
          size_t inbytes_left,
          char *outbuf,
          size_t outbytes_left)
      
      to get rid of that warning, then try to tackle the actual error.
    2. first find CODESET, well I can't... so find the definition of nl_langinfo:
      anubis@ariel$ grep -r nl_langinfo /usr/local/include/*.h
      anubis@ariel$ grep -r CODESET /usr/local/include/*.h
      anubis@ariel$ grep -r nl_langinfo /usr/include/*.h
      /usr/include/langinfo.h:char *nl_langinfo(nl_item);
      
      and find that it depends on nl_item:
      char *nl_langinfo(nl_item);
      
      but of course that's not defined there =) in /usr/include/nl_types.h it is simply a typedef to long, so... what should it's value be?
      At least this gave good info to plug into google.com/bsd:
      http://mail-index.netbsd.org/tech-userlevel/2003/01/24/0005.html
      which points to this [1]:
      http://www.iana.org/assignments/character-sets

      I may be on path... now I'm assuming that what's happening in src/utf8.c is that it calls:
      cs = nl_langinfo(CODESET)
      
      looking for a result on that page, such as: US-ASCII using a CODESET of 3 from the MIB defined on the IANA character-sets page, so in src/utf8.h I added:
      #define CODESET	3
      
      and got past that error!
      Got all the way to linking apparently:
      cc -o gtk-gnutella (skip a screenfull of object files)
      utf8.o: Undefined symbol `_libiconv_open' referenced (use -liconv ?)
      utf8.o: Undefined symbol `_libiconv' referenced (use -liconv ?)
      collect2: ld returned 1 exit status
      *** Error code 1
      
      Stop in /home/anubis/gtk-gnutella-0.93.3/src (line 398 of Makefile).
      Making all in pixmaps...
      Making all in po...
      
  5. so back to the beginning and include -liconv in the Configure step...
    Any additional libraries? [-lz -lintl -lresolv] -lz -lintl -lresolv -liconv
    
    Then after the warnings from make depend, make the changes listed above where needed (use /usr/bin/mkdep during Configure, and modify config.h to use the BSD value from sys/params.h)
    make
    sudo make install
    
    all looks good so far, now to run it ...
    ... and it's been up for over an hour =)

1

Apparently the IANA naming convention used by gtk-gnutella in this case is GNU-specific. After digging around a little on the NetBSD mailing list from the post mentioned above, all I could do is point to additional discussion on it.

There is what looks like a solution, here's a python cvs diff file showing how it's handled there: