c++ - 如何使用 Cygwin 构建 Google RE2?

标签 c++ windows cygwin

我收到这些错误:

g++: unrecognized option '-pthread'
util/test.cc:1:0: warning: -fPIC ignored for target (all code is position independent)

(多个),最后:

/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lre2 collect2: ld returned 1 exit status

有什么建议吗?

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

最佳答案

我做了以下事情来编译 re2 库并在 cygwin 上进行测试

1)库的编译安装

hg clone https://re2.googlecode.com/hg re2
cd re2
make
make install

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)

然后做

进行测试

为我编译的库没有问题,除了一个所有测试都通过了。

如果您只需要 Windows 版本的库,您也可以检查此版本的 re2 for Visual Studio。 http://code.google.com/p/re2win/

关于c++ - 如何使用 Cygwin 构建 Google RE2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8284982/

相关文章:

Cygwin 路径到/cygdrive/C/Program Files (x86)/GnuWin32 目录?

linux - 如何清理 bash 中分隔符也在双引号内的 csv?

c++ - 将数据从 PC 发送到微 Controller

C++ 使用信号量代替忙等待

c - 链接器选项,路径总和太长?

java - 如何从 Windows 命令行永久更新 PATH 变量?

c++ - 如何在派生类型的容器与基类型的容器之间进行转换

c++ - 创建动态二维数组的其他方法?

windows - 将多个文件通过管道传输到一个批处理文件中(使用资源管理器突出显示)

c++ - 编译报错cygwin regex.h No such file or directory