Building ohcount on OS X

Avatar

tux_rocker

about 1 year ago

When trying to build ohcount on OS X, I get:

computer-van-reinier-lamers:~/Source/ohcount reinier$ rake

(in /Users/reinier/Source/ohcount)

/Users/reinier/Source/ohcount/test/unit/*_test.rb

/usr/local/bin/ruby extconf.rb

checking for pcre_compile() in -lpcre... no

BUILD_TYPE: RELEASE

creating Makefile

make

gcc -I. -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I. -fno-common -g -O2 -fno-common -pipe -fno-common -g -O2 -Wall -DNDEBUG
-arch i386 -c common.c

In file included from common.c:1:

common.h:32:18: error: pcre.h: No such file or directory

In file included from common.h:35, from common.c:1: compiled_state.h:13: error: parse error before 'pcre' compiled_state.h:13: warning: no semicolon at end of struct or union compiledstate.h:14: warning: type defaults to 'int' in declaration of 'pcreextra' compiled_state.h:14: warning: data definition has no type or storage class compiled_state.h:16: error: parse error before '}' token compiled_state.h:16: warning: type defaults to 'int' in declaration of 'CompiledState' compiled_state.h:16: warning: data definition has no type or storage class compiled_state.h:19: error: parse error before '*' token compiled_state.h:20: error: parse error before '*' token In file included from common.h:36, from common.c:1: polyglot.h:14: error: parse error before 'CompiledState' polyglot.h:14: warning: no semicolon at end of struct or union polyglot.h:16: error: parse error before '}' token polyglot.h:16: warning: type defaults to 'int' in declaration of 'Polyglot' polyglot.h:16: warning: data definition has no type or storage class polyglot.h:18: error: parse error before '*' token polyglot.h:19: error: parse error before '*' token In file included from common.h:37, from common.c:1: polyglots.h:12: error: parse error before '*' token polyglots.h:12: warning: type defaults to 'int' in declaration of 'POLYGLOTS' polyglots.h:12: warning: data definition has no type or storage class In file included from common.h:39, from common.c:1: parser.h:32: error: parse error before 'Polyglot' common.c: In function 'die': common.c:5: warning: implicit declaration of function 'exit' common.c:5: warning: incompatible implicit declaration of built-in function 'exit' make: * [common.o] Error 1 rake aborted! Command failed with status (2): [make...] /Users/reinier/Source/ohcount/rakefile:64

I have installed PCRE via fink but gcc is not looking at the PCRE headers during the build. Manually fixing the Makefile in ext/ can get me beyond this error, but then gives me a dynamic linker error. Is there a nice way to build ohcount on OS X?


Avatar

Robin Luckey

about 1 year ago

Hi tux_rocker,

I do all of my development on a Mac, so building under OS X really should be the cleanest way to go!

We rely on the ruby lib 'mkmf' to do the heavy lifting here. This lib is supposed to find the pcre library and instruct gcc where to find it. Try this:

~$ irb
irb(main):001:0> require 'mkmf'
=> true
irb(main):002:0> have_library('pcre','pcre_compile')
checking for pcre_compile() in -lpcre... yes
=> true

If you don't get true responses at each step, you have problems either with mkmf or pcre.

It's been a long time, but I believe I installed pcre on my Mac using DarwinPorts (sudo port install pcre). That might give you better results than fink. I'm running pcre 6.7.0, which is pretty old.

Let me know what the irb results are, and try installing with DarwinPorts. I'll have time to help you investigate this some more tomorrow.

Thanks, Robin


Avatar

tux_rocker

about 1 year ago

I installed PCRE from MacPorts after removing it with fink. Then I get:

irb(main):001:0> require 'mkmf'

=> true

irb(main):002:0> havelibrary 'pcre', 'pcrecompile'

checking for pcre_compile() in -lpcre... no

=> false

irb(main):003:0>


Avatar

tux_rocker

about 1 year ago

I fixed it by installing Ruby from MacPorts, too.


Avatar

Robin Luckey

about 1 year ago

Hmm, I'm sorry you had so much trouble getting this set up. I seem to recall having trouble getting Ruby set up on my own laptop a long time ago.

I think OS X 10.4 comes with a version of Ruby pre-installed that you can't easily uninstall with a package manager; and it's a pretty old and oddly-configured version of Ruby. It's been a while so my memory of this is shaky.

It would be nice to put together some good directions for getting this all running on Mac OS X from scratch, but unfortunately that mean reinstalling a clean OS on one of our Macs. We need an intern :-).

Hopefully your notes above may help the next victim.

Thanks, Robin


Avatar

tux_rocker

about 1 year ago

So my recipe was:

  1. Install PCRE with MacPorts
  2. Install Ruby with MacPorts
  3. Adjust your PATH environment variable in .bashrc such that typing 'ruby' loads the MacPorts ruby, not the one that comes with Tiger by default
  4. Install RubyGems from MacPorts
  5. gem install rake
  6. Execute 'rake' in the ohcount source directory

That's not too hard :-)

The Ruby I originally tried to build ohcount with was not the one that Apple ships, but came from some binary package that's advertised on the web to get up and running with Ruby on Rails quickly.


Avatar

Robin Luckey

about 1 year ago

Hi tux_rocker,

I finally discovered your Haskell patch over on labs.ohloh.net (for some reason my timeline report wasn't showing your patch submission).

I'm psyched to get Haskell into our line counter, but I had some trouble with the Git patches (sigh). More info in the Trac ticket.

Thanks,

Robin


Avatar

Andy Verprauskus

about 1 year ago

tux_rocker, thanks for the OSX instructions


Avatar

dartar

about 1 year ago

Has anyone tried to build ohcount on Leopard? A how-to similar to the Ubuntu/Gentoo/ArchLinux pages would be very useful.


Avatar

Robin Luckey

about 1 year ago

I build Ohcount on Leopard every day. The problem is, my machine has a two-year hodge-podge of ports, finks, build-from-source's, upgrades, and rm -rf's that make it impossible to figure out how my machine got into this state. Ironically, because it's the platform I use most, it's the platform I can least describe.

The Ubuntu instructions resulted from the magical ability to install a clean server image on a virtual box in just a few minutes to confirm the instructions. I have no such capability on Leopard, as far as I know.

I agree such a set of instructions would be helpful. Anyone know how to get a clean Leopard install in a virtual box?


Avatar

dartar

about 1 year ago

ok I followed tux_rocker's instructions on Mac 10.5.2 but I'm stuck at point vi. When I try to build ohcount, I get error messages that suggest the built-in version of Ruby is used instead of the one downloaded via MacPorts:

gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -g -O2 -Wall -DNDEBUG -c common.c

I have changed my path in .tcshrc so that the Macports paths come earlier than /usr/bin, am I missing something in point iii.?


Avatar

Robin Luckey

about 1 year ago

I'm just guessing here, since I can't really see your error in what you pasted above.

However, the path fix is probably not enough. As some grepping will reveal, many evil-doers put the full path to /usr/bin/ruby in the shebang line of their scripts.

In /usr/bin, try replacing /usr/bin/ruby with a symlink to the MacPorts version. It's hardcore, but it tends to work.


Avatar

Adrian Kosmaczewski

about 1 year ago

I've found a solution to this problem, at least for PPC Leopard (on a G4 PowerBook), please take a look here Hope this helps! :) Cheers