2
votes

Gurus!

I am using Ubuntu 13.10 64-bit to compile latest Google RE2 library, but 'make testinstall' failed to compile, here is the log:

kevin@ubuntu:~/re2$ make testinstall

cp testinstall.cc obj (cd obj && g++ -I/usr/local/include -L/usr/local/lib testinstall.cc -lre2 -pthread -o testinstall) /tmp/ccSsaSXS.o: In function main': testinstall.cc:(.text+0xce): undefined reference tore2::FilteredRE2::FirstMatch(re2::StringPiece const&, std::vector > const&) const' /usr/local/lib/libre2.so: undefined reference to pthread_rwlock_rdlock' /usr/local/lib/libre2.so: undefined reference topthread_rwlock_wrlock' /usr/local/lib/libre2.so: undefined reference to pthread_rwlock_destroy' /usr/local/lib/libre2.so: undefined reference topthread_rwlock_init' /usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_unlock' collect2: error: ld returned 1 exit status make: * [testinstall] Error 1

I tried to replace -pthread with -lpthread, still failed, then I dumped libre2.so and found that pthread_xxx is in it. Here is the issue tracking in RE2 forum: https://code.google.com/p/re2/issues/detail?id=100

Anyone here have ever complied RE2 successfully ? Thank you!

5

5 Answers

1
votes

See this comment:

Adding -pthread to LDFLAGS seems to fix make test (all tests are passing), but not make testinstall.

That will get you to the next error

0
votes

Depending on what you build it for 'make testinstall' might not be necessary. I just needed to get python re2 port working, and this can be installed after running make install.

0
votes

I encounter this problem before. Modify the makefile and use -lpthread instead of -pthread.

0
votes

So I tried looking for the lines in testinstall.cc that were causing the symbol errors and I found out that the only line was on line 18:

18 - f.firstMatch(:abbccc:, ids);

I commented this line out (so that the FullMatch function below is still called) and just ran g++ testinstall.cc -lre2 -pthread -o testinstall (basically what the Makefile does) and I was able to get a binary successfully. Although this might not really solve the problem, its good to know that we can still use the RE2::Fullmatch and partial match functions

If I were to guess, maybe there is a dependency somewhere inside the filtered_re2 module?

0
votes

I had the same problem. But if you compile with -static everything goes well.

nm -C shows that the "missing" symbol exists in both .a and .so files.