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.
Unix OSC++

Avatar of undefined
Last Comment
bejhan

8/22/2022 - Mon
sarabande

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
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?
sarabande

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
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
sarabande

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
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
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.
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
bejhan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
bejhan

ASKER
Found own solution.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23