{"id":170,"date":"2007-01-16T06:36:18","date_gmt":"2007-01-15T21:36:18","guid":{"rendered":"https:\/\/fugutabetai.com\/blog\/2007\/01\/16\/building-libbow-and-rainbow-on-mac-osx\/"},"modified":"2007-01-16T06:36:18","modified_gmt":"2007-01-15T21:36:18","slug":"building-libbow-and-rainbow-on-mac-osx","status":"publish","type":"post","link":"https:\/\/fugutabetai.com\/blog\/2007\/01\/16\/building-libbow-and-rainbow-on-mac-osx\/","title":{"rendered":"Building libbow and rainbow on Mac OSX"},"content":{"rendered":"<p>For some research work I&#8217;m doing, I would like to do some Bayesian modeling for text categorization.  Since I&#8217;m not interested in re-inventing wheels when there are plenty of very well constructed wheels available for the taking, I thought I would install <a href=\"http:\/\/www.cs.umass.edu\/~mccallum\/\">Andrew McCallum&#8217;s<\/a> <a href=\"http:\/\/www.cs.cmu.edu\/~mccallum\/bow\/\">libbow<\/a> and <a href=\"http:\/\/www.cs.cmu.edu\/~mccallum\/bow\/rainbow\/\">rainbow<\/a> packages on my Mac.  Of course, I had a little bit of trouble, and thought it would be a good idea to document how I went about installing since a quick google search didn&#8217;t turn much up.  (Not quite true: I turned up one or two references to the packages being available via <a href=\"http:\/\/fink.sourceforge.net\/\">fink<\/a>, but I couldn&#8217;t find them in my setup.)  <\/p>\n<p><P\/> Details follow the read more link.  <P\/><br \/>\n<!-- readmore --><\/p>\n<h3>Apple Technote on porting command line tools<\/h3>\n<p><a href=\"http:\/\/developer.apple.com\/technotes\/tn2002\/tn2071.html\">This Apple Technote on porting command line tools<\/a> has some interesting information on header files and other gotchas when working on OSX.  <\/p>\n<p><P\/><\/p>\n<p>The first problem was <\/p>\n<pre>\r\nmake\r\ngcc -c   -Ibow -I. -I.\/argp -DHAVE_STRERROR=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_RANDOM=1 -DHAVE_SRANDOM=1 -DHAVE_SETENV=1 -DHAVE_STRCHR=1 -DHAVE_STRRCHR=1 -DHAVE_LOG2F=1 -DHAVE_SQRTF=1 -DHAVE_ALLOCA_H=1  -g -O -Wall -Wimplicit -o array.o array.c\r\nIn file included from array.c:22:\r\n.\/bow\/libbow.h:40:53: error: malloc.h: No such file or directory\r\n<\/pre>\n<p>This isn&#8217;t really a big shock, since Apple has their malloc.h header off in <code>\/usr\/include\/sys\/<\/code>, where GCC wouldn&#8217;t be able to find it.  Since in OSX and other POSIX implementations the <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/malloc.html\">malloc functions are included in stdlib.h<\/a> I just removed all references to mallo.h from the code.  <\/p>\n<p><P\/><\/p>\n<p>That went well, and got me up to <\/p>\n<pre>\r\ngcc -c   -Ibow -I. -I.\/argp -DHAVE_STRERROR=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_RANDOM=1 -DHAVE_SRANDOM=1 -DHAVE_SETENV=1 -DHAVE_STRCHR=1 -DHAVE_STRRCHR=1 -DHAVE_LOG2F=1 -DHAVE_SQRTF=1 -DHAVE_ALLOCA_H=1  -g -O -Wall -Wimplicit -o array.o array.c\r\nIn file included from array.c:22:\r\n.\/bow\/libbow.h:1631: warning: type qualifiers ignored on function return type\r\n.\/bow\/libbow.h:2128: error: array type has incomplete element type\r\n<\/pre>\n<p>The warning isn&#8217;t a big deal, but the error is a bit more troubling.  This pops up because GCC has become more strict about following the C++ spec on incomplete types (<a href=\"http:\/\/gcc.gnu.org\/ml\/gcc\/2005-02\/msg00053.html\">a question on a similar problem<\/a>, see the two follow-ups as well.)  I could try to track things down and make sure that<br \/>\nthe <code>extern struct argp_child bow_argp_children[];<\/code> line has the argp_child struct defined before that line, but I thought it was easier to change the version of gcc to 3.3.  Apple ships with a few gcc compilers installed, you can use <code>gcc_select<\/code> to list (-l) and change the default system compiler.  I changed to 3.3.  That got me up to:<\/p>\n<pre>\r\nbarrel.c:22:20: values.h: No such file or directory\r\nbarrel.c: In function `barrel_iterator_count_for_doc':\r\nbarrel.c:1182: warning: division by zero\r\n<\/pre>\n<p>A quick search of the web turned up the nugget that values.h has been replaced by float.h, so over in the barrel.c file and bow\/svm.h I replaced <code>#include &lt;values.h&gt;<\/code> with <code>#include &lt;float.h&gt;<\/code> and things went fine, until I ran across a new error:<\/p>\n<pre>\r\nsvm_smo.c:194: error: `MAXDOUBLE' undeclared (first use in this function)\r\nsvm_smo.c:194: error: (Each undeclared identifier is reported only once\r\nsvm_smo.c:194: error: for each function it appears in.)\r\n<\/pre>\n<p>This was an artifact of swapping in limits.h for values.h, MAXDOUBLE is now called DBL_MAX, so making that change in the broken file fixed that problem.  That actually compiled all of the object files, so now we just have to deal with linking.  Here&#8217;s a new error:<\/p>\n<pre>\r\nld: can't locate file for: -lcrypt\r\n<\/pre>\n<p>It looks like the problem here is that libcrypt does not exist for OSX.  Instead, you can try using libcrypto.  What are the differences?  I have no idea.  So in Makefile.in, I added an &#8220;o&#8221; to the ALL_LIBS line that specified libcrypt, re-configured, re-made, and then a make install and things are installed wonderfully.  Time to do some model building.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some research work I&#8217;m doing, I would like to do some Bayesian modeling for text categorization. Since I&#8217;m not interested in re-inventing wheels when there are plenty of very well constructed wheels available for the taking, I thought I would install Andrew McCallum&#8217;s libbow and rainbow packages on my Mac. Of course, I had [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,5],"tags":[],"_links":{"self":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts\/170"}],"collection":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":0,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"wp:attachment":[{"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fugutabetai.com\/blog\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}