如何使用 Cygwin 构建 Google RE2?
我收到这些错误:
g++:无法识别的选项“-pthread”
util/test.cc:1:0:警告:目标忽略 -fPIC(所有代码均与位置无关)
(多个),最后:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld:找不到-lre2 collect2:ld返回1退出状态
有什么建议吗?
UPD 完整编译器日志
g++ -o obj/so/test/charclass_test obj/so/re2/testing/charclass_test.o obj/so/util/pcre.o obj/so/util/random.o obj/so/util/thread.o obj/so/re2/testing/backtrack.o obj/so/re2/testing/dump.o obj/so/re2/testing/exhaustive_tester.o obj/so/re2/testing/null_walker.o obj/so/re2/testing/regexp_generator.o obj/so/re2/testing/string_generator.o obj/so/re2/testing/tester.o obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a -pthread
g++: unrecognized option '-pthread'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lre2
collect2: ld returned 1 exit status
make: *** [obj/so/test/charclass_test] Error 1
I'm getting these errors:
g++: unrecognized option '-pthread'
util/test.cc:1:0: warning: -fPIC ignored for target (all code is position independent)
(multiple), and finally:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lre2
collect2: ld returned 1 exit status
Any advice?
UPD full compiler log
g++ -o obj/so/test/charclass_test obj/so/re2/testing/charclass_test.o obj/so/util/pcre.o obj/so/util/random.o obj/so/util/thread.o obj/so/re2/testing/backtrack.o obj/so/re2/testing/dump.o obj/so/re2/testing/exhaustive_tester.o obj/so/re2/testing/null_walker.o obj/so/re2/testing/regexp_generator.o obj/so/re2/testing/string_generator.o obj/so/re2/testing/tester.o obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a -pthread
g++: unrecognized option '-pthread'
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lre2
collect2: ld returned 1 exit status
make: *** [obj/so/test/charclass_test] Error 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了以下事情来编译 re2 库并在 cygwin 上进行测试
1)编译和安装库
2)编译测试。
修改
Makefile
并替换此行:$(CXX) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
包含此行
$(CXX) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -L/usr/local/lib -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
然后进行
make test
为我编译的库没有问题,除了一个例外,所有测试都通过了。
如果您只需要 Windows 版本的库,您也可以检查此版本的 re2 for Visual Studio。
http://code.google.com/p/re2win/
I've done the following things to compile re2 library and tests on cygwin
1) Compilation and instalation of library
2) Compilation of tests.
Modify
Makefile
and replace this line:$(CXX) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -Lobj/so -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
with this line
$(CXX) -o $@ obj/so/re2/testing/$*.o $(STESTOFILES) obj/so/util/test.o -L/usr/local/lib -lre2 obj/libre2.a $(LDFLAGS) $(LDPCRE)
And after that do
make test
Library compiled for me without problem and with exception to one all tests passed.
You may also check this version of re2 for Visual Studio if you just need Windows version of library.
http://code.google.com/p/re2win/
您可以更改Makefile以通过编译。然而,测试仍然会失败。我建议您联系 hg 项目所有者,了解为什么这在 cygwin 上不起作用。
You can change the Makefile to pass the compilation. However, the test will still fail. I'd suggest you contact hg project owner to see why this does not work on cygwin.