Link to home
Start Free TrialLog in
Avatar of bejhan
bejhan

asked on

Cannot compile Google RE2 on Solaris

I want to use Google's regular expression library, RE2 (http://code.google.com/p/re2/). But I can't get it to compile on Solaris. However, I have got it to compile on a generic linux (which has an older GCC) so I'm not sure what the problem is.

On the installation instructions (http://code.google.com/p/re2/wiki/Install) it says to use gmake which spits out some random error:
/bin/sh: syntax error at line 1: `(' unexpected
gmake: *** [obj/dbg/util/arena.o] Error 2

Open in new window


I have tried regular make, but it doesn't like the Makefile.
Avatar of sarabande
sarabande
Flag of Luxembourg image

it looks more a compiler and environment issue rather than other.

i would install newest gcc for solaris and sunstudio. the latter should allow you to create a makefile that is compatible to the environment which unfortunately is different than to that of most standard linux.

Sara
Avatar of bejhan
bejhan

ASKER

I don't have privilege to install another gcc. The gcc on the solaris box is newer than on the generic linux box (which I successfully built RE2 on). So the gcc version I have should be sufficient should it?

Is there anyway to get gmake to output some useful messages rather than that garbage so I can actually see what the problem is?
i doubt that gmake is the right command. unfortunately most environments of solaris i worked with had special home-made tools and i wasn't responsible for them. can you spot the gcc and try to use gcc directly not using a makefile? only to check if you have the right environment. if that works you may look for a makefile (any) named GNUMakefile (don't know exactly if i have the correct case so do a case-independent search on the file). if you find some you could step into the folder and try make. if that compiles you should be able to find out from that makefile how to adopt yours.

Sara
Avatar of bejhan

ASKER

The Makefile is actually using g++, but I don't think I could use g++ directly because the Makefile is very complex with dependencies, etc.

Maybe we could get the Makefile to work with the regular make command (rather than gmake).

First make complains of an unexpected end of line on line 41:

40: ifeq ($(shell uname),Darwin)
41: MAKE_SHARED_LIBRARY=g++ -dynamiclib $(LDFLAGS) -exported_symbols_list libre2.symbols.darwin
42: else
43: MAKE_SHARED_LIBRARY=g++ -shared -Wl,-soname,libre2.so.0,--version-script=libre2.symbols $(LDFLAGS)
45: endif

Open in new window


Since I know we are using zsh not Darwin, I commented out lines 40, 41, 42, 45.

Now make complains of an unexpected end of line on line 207. Line 207 is just blank so I am confused.
Makefile
check the makefile with vi. it will show the end-of-line characters. you may have only linefeed 0x0a but not 0x0a0d.

i think it is not an error but only warning. does it compile with make?

Sara
Avatar of bejhan

ASKER

It does not compile with make, this is a fatal error:
make: Fatal error in reader: Makefile, line 207: Unexpected end of line seen

Open in new window


Line 207 has a new line following the format of the newline on every other line.
I see no real difference with the target on lines 200-203 and the target on lines 204-207.

This error is really strange...
error-area.PNG
Avatar of bejhan

ASKER

I think I should be using gmake, because this is GNU Make (where as my make command is some custom make that does not like this makefile).

I found an article (http://blog.leecarmichael.com/2009/02/weird-makegmake-error.html) which describes similar behaviour to my original gmake error
/bin/sh: syntax error at line 1: `(' unexpected
gmake: *** [obj/dbg/util/arena.o] Error 2

Open in new window


In the article he explains that the bash shell must be used with gmake so that certain features can be used.
However, my gmake is executing under sh instead of bash.

I have tried entering a bash shell (by typing bash), but gmake still uses sh.
I have tried aliasing sh to bash, same result.
I have tried adding #!/bin/sh to the top of the make file, same result.
Avatar of bejhan

ASKER

After more investigation, I don't think it has to with the shell.

I used truss to investigate the actual commands being executed.
Prior to spitting out the error the following is executed:
16067:   argv: /bin/sh -c mkdir -p $(dirname obj/util/arena.o)

Open in new window


This seems incorrect because $(dirname obj/util/arena.o) should actually resolve to obj/util.

I think this is an aliasing problem (i.e. dirname is not an actual gmake function, the dir function seems to have the intended behavior though).
SOLUTION
Avatar of bejhan
bejhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bejhan

ASKER

Found own solution.