3

我想使用 C++ 程序Apache Thrift进行一些开发,我将在其中更改一些源代码并尝试为开源社区贡献一些代码。为此,我需要能够从源代码构建和安装 Apache Thrift,但是当我尝试构建它时遇到了一些错误。

我在 Google 上搜索过,但找不到任何可以解决我一直遇到的问题的答案。我正在运行 OSX Mountain Lion 10.8.2,我想我已经安装了http://thrift.apache.org/docs/install/中列出的所有要求。

我认为真正的问题是当我跑步时make(如果你现在想查看该信息,请向下滚动),但以防万一,我将提及所有内容。

当我按照http://thrift.apache.org/docs/BuildingFromSource/./bootstrap.sh的说明在 thrift 文件夹中运行时,我会在输出顶部收到一些警告,但我认为它们不是问题,因为我已经在“成功的构建”中看到了它们。以下是警告:

configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions
configure.ac: warning: missing AC_CHECK_HEADERS([wchar.h]) wanted by: lib/py/compat/win32/stdint.h:52 

如果需要,这里是./bootstrap.sh命令的整个输出:

Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions
configure.ac: warning: missing AC_CHECK_HEADERS([wchar.h]) wanted by: lib/py/compat/win32/stdint.h:52
configure.ac:103: installing './config.guess'
configure.ac:103: installing './config.sub'
configure.ac:26: installing './install-sh'
configure.ac:26: installing './missing'
compiler/cpp/Makefile.am: installing './depcomp'
configure.ac: installing './ylwrap'
lib/cpp/test/Makefile.am:178: warning: variable 'concurrency_test_SOURCES' is defined but no program or
lib/cpp/test/Makefile.am:178: library has 'concurrency_test' as canonical name (possible typo)
lib/cpp/test/Makefile.am:187: warning: variable 'processor_test_SOURCES' is defined but no program or
lib/cpp/test/Makefile.am:187: library has 'processor_test' as canonical name (possible typo)
lib/cpp/test/Makefile.am:195: warning: variable 'processor_test_LDADD' is defined but no program or
lib/cpp/test/Makefile.am:195: library has 'processor_test' as canonical name (possible typo)
lib/cpp/test/Makefile.am:184: warning: variable 'concurrency_test_LDADD' is defined but no program or
lib/cpp/test/Makefile.am:184: library has 'concurrency_test' as canonical name (possible typo)

接下来,我运行./configure它似乎成功运行。当我尝试将输出放入我的帖子中时,我的字符用完了,所以如果需要,我将整个输出放入Google Doc中。

接下来我尝试运行make它记录一堆错误。我认为罪魁祸首可能是第一个错误:

thriftl.ll:51:21: error: thrifty.h: No such file or directory

我不知道如何解决这个错误。以防万一,这里是make命令的整个输出:

make  all-recursive
Making all in compiler/cpp
make  all-am
\
     \
    /bin/sh ../../ylwrap `test -f 'src/thrifty.yy' || echo './'`src/thrifty.yy y.tab.c thrifty.cc y.tab.h `echo thrifty.cc | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output thrifty.output -- bison -y -d 
thrifty.hh is unchanged
g++ -DHAVE_CONFIG_H -I. -I../..  -I./src  -Wall -Wno-sign-compare -Wno-unused -g -O2 -MT libparse_a-thrifty.o -MD -MP -MF .deps/libparse_a-thrifty.Tpo -c -o libparse_a-thrifty.o `test -f 'thrifty.cc' || echo './'`thrifty.cc
mv -f .deps/libparse_a-thrifty.Tpo .deps/libparse_a-thrifty.Po
\
     \
    /bin/sh ../../ylwrap `test -f 'src/thriftl.ll' || echo './'`src/thriftl.ll lex.yy.c thriftl.cc -- flex  
g++ -DHAVE_CONFIG_H -I. -I../..  -I./src  -Wall -Wno-sign-compare -Wno-unused -g -O2 -MT libparse_a-thriftl.o -MD -MP -MF .deps/libparse_a-thriftl.Tpo -c -o libparse_a-thriftl.o `test -f 'thriftl.cc' || echo './'`thriftl.cc
thriftl.ll:51:21: error: thrifty.h: No such file or directory
thriftl.ll: In function ‘int yylex()’:
thriftl.ll:114: error: ‘yylval’ was not declared in this scope
thriftl.ll:114: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:115: error: ‘yylval’ was not declared in this scope
thriftl.ll:115: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:117: error: ‘tok_namespace’ was not declared in this scope
thriftl.ll:118: error: ‘tok_cpp_namespace’ was not declared in this scope
thriftl.ll:119: error: ‘tok_cpp_include’ was not declared in this scope
thriftl.ll:120: error: ‘tok_cpp_type’ was not declared in this scope
thriftl.ll:121: error: ‘tok_java_package’ was not declared in this scope
thriftl.ll:122: error: ‘tok_cocoa_prefix’ was not declared in this scope
thriftl.ll:123: error: ‘tok_csharp_namespace’ was not declared in this scope
thriftl.ll:124: error: ‘tok_delphi_namespace’ was not declared in this scope
thriftl.ll:125: error: ‘tok_php_namespace’ was not declared in this scope
thriftl.ll:126: error: ‘tok_py_module’ was not declared in this scope
thriftl.ll:127: error: ‘tok_perl_package’ was not declared in this scope
thriftl.ll:128: error: ‘tok_ruby_namespace’ was not declared in this scope
thriftl.ll:129: error: ‘tok_smalltalk_category’ was not declared in this scope
thriftl.ll:130: error: ‘tok_smalltalk_prefix’ was not declared in this scope
thriftl.ll:131: error: ‘tok_xsd_all’ was not declared in this scope
thriftl.ll:132: error: ‘tok_xsd_optional’ was not declared in this scope
thriftl.ll:133: error: ‘tok_xsd_nillable’ was not declared in this scope
thriftl.ll:134: error: ‘tok_xsd_namespace’ was not declared in this scope
thriftl.ll:135: error: ‘tok_xsd_attrs’ was not declared in this scope
thriftl.ll:136: error: ‘tok_include’ was not declared in this scope
thriftl.ll:137: error: ‘tok_void’ was not declared in this scope
thriftl.ll:138: error: ‘tok_bool’ was not declared in this scope
thriftl.ll:139: error: ‘tok_byte’ was not declared in this scope
thriftl.ll:140: error: ‘tok_i16’ was not declared in this scope
thriftl.ll:141: error: ‘tok_i32’ was not declared in this scope
thriftl.ll:142: error: ‘tok_i64’ was not declared in this scope
thriftl.ll:143: error: ‘tok_double’ was not declared in this scope
thriftl.ll:144: error: ‘tok_string’ was not declared in this scope
thriftl.ll:145: error: ‘tok_binary’ was not declared in this scope
thriftl.ll:146: error: ‘tok_slist’ was not declared in this scope
thriftl.ll:147: error: ‘tok_senum’ was not declared in this scope
thriftl.ll:148: error: ‘tok_map’ was not declared in this scope
thriftl.ll:149: error: ‘tok_list’ was not declared in this scope
thriftl.ll:150: error: ‘tok_set’ was not declared in this scope
thriftl.ll:151: error: ‘tok_oneway’ was not declared in this scope
thriftl.ll:152: error: ‘tok_typedef’ was not declared in this scope
thriftl.ll:153: error: ‘tok_struct’ was not declared in this scope
thriftl.ll:154: error: ‘tok_union’ was not declared in this scope
thriftl.ll:155: error: ‘tok_xception’ was not declared in this scope
thriftl.ll:156: error: ‘tok_extends’ was not declared in this scope
thriftl.ll:157: error: ‘tok_throws’ was not declared in this scope
thriftl.ll:158: error: ‘tok_service’ was not declared in this scope
thriftl.ll:159: error: ‘tok_enum’ was not declared in this scope
thriftl.ll:160: error: ‘tok_const’ was not declared in this scope
thriftl.ll:161: error: ‘tok_required’ was not declared in this scope
thriftl.ll:162: error: ‘tok_optional’ was not declared in this scope
thriftl.ll:165: error: ‘tok_oneway’ was not declared in this scope
thriftl.ll:275: error: ‘yylval’ was not declared in this scope
thriftl.ll:279: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:284: error: ‘yylval’ was not declared in this scope
thriftl.ll:288: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:292: error: ‘yylval’ was not declared in this scope
thriftl.ll:293: error: ‘tok_dub_constant’ was not declared in this scope
thriftl.ll:297: error: ‘yylval’ was not declared in this scope
thriftl.ll:298: error: ‘tok_identifier’ was not declared in this scope
thriftl.ll:302: error: ‘yylval’ was not declared in this scope
thriftl.ll:303: error: ‘tok_st_identifier’ was not declared in this scope
thriftl.ll:347: error: ‘yylval’ was not declared in this scope
thriftl.ll:348: error: ‘tok_literal’ was not declared in this scope
make[3]: *** [libparse_a-thriftl.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

而且,虽然我怀疑它是否需要,因为我认为错误在make,最后一个输出 - sudo make install

Making install in compiler/cpp
make  install-am
g++ -DHAVE_CONFIG_H -I. -I../..  -I./src  -Wall -Wno-sign-compare -Wno-unused -g -O2 -MT libparse_a-thriftl.o -MD -MP -MF .deps/libparse_a-thriftl.Tpo -c -o libparse_a-thriftl.o `test -f 'thriftl.cc' || echo './'`thriftl.cc
thriftl.ll:51:21: error: thrifty.h: No such file or directory
thriftl.ll: In function ‘int yylex()’:
thriftl.ll:114: error: ‘yylval’ was not declared in this scope
thriftl.ll:114: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:115: error: ‘yylval’ was not declared in this scope
thriftl.ll:115: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:117: error: ‘tok_namespace’ was not declared in this scope
thriftl.ll:118: error: ‘tok_cpp_namespace’ was not declared in this scope
thriftl.ll:119: error: ‘tok_cpp_include’ was not declared in this scope
thriftl.ll:120: error: ‘tok_cpp_type’ was not declared in this scope
thriftl.ll:121: error: ‘tok_java_package’ was not declared in this scope
thriftl.ll:122: error: ‘tok_cocoa_prefix’ was not declared in this scope
thriftl.ll:123: error: ‘tok_csharp_namespace’ was not declared in this scope
thriftl.ll:124: error: ‘tok_delphi_namespace’ was not declared in this scope
thriftl.ll:125: error: ‘tok_php_namespace’ was not declared in this scope
thriftl.ll:126: error: ‘tok_py_module’ was not declared in this scope
thriftl.ll:127: error: ‘tok_perl_package’ was not declared in this scope
thriftl.ll:128: error: ‘tok_ruby_namespace’ was not declared in this scope
thriftl.ll:129: error: ‘tok_smalltalk_category’ was not declared in this scope
thriftl.ll:130: error: ‘tok_smalltalk_prefix’ was not declared in this scope
thriftl.ll:131: error: ‘tok_xsd_all’ was not declared in this scope
thriftl.ll:132: error: ‘tok_xsd_optional’ was not declared in this scope
thriftl.ll:133: error: ‘tok_xsd_nillable’ was not declared in this scope
thriftl.ll:134: error: ‘tok_xsd_namespace’ was not declared in this scope
thriftl.ll:135: error: ‘tok_xsd_attrs’ was not declared in this scope
thriftl.ll:136: error: ‘tok_include’ was not declared in this scope
thriftl.ll:137: error: ‘tok_void’ was not declared in this scope
thriftl.ll:138: error: ‘tok_bool’ was not declared in this scope
thriftl.ll:139: error: ‘tok_byte’ was not declared in this scope
thriftl.ll:140: error: ‘tok_i16’ was not declared in this scope
thriftl.ll:141: error: ‘tok_i32’ was not declared in this scope
thriftl.ll:142: error: ‘tok_i64’ was not declared in this scope
thriftl.ll:143: error: ‘tok_double’ was not declared in this scope
thriftl.ll:144: error: ‘tok_string’ was not declared in this scope
thriftl.ll:145: error: ‘tok_binary’ was not declared in this scope
thriftl.ll:146: error: ‘tok_slist’ was not declared in this scope
thriftl.ll:147: error: ‘tok_senum’ was not declared in this scope
thriftl.ll:148: error: ‘tok_map’ was not declared in this scope
thriftl.ll:149: error: ‘tok_list’ was not declared in this scope
thriftl.ll:150: error: ‘tok_set’ was not declared in this scope
thriftl.ll:151: error: ‘tok_oneway’ was not declared in this scope
thriftl.ll:152: error: ‘tok_typedef’ was not declared in this scope
thriftl.ll:153: error: ‘tok_struct’ was not declared in this scope
thriftl.ll:154: error: ‘tok_union’ was not declared in this scope
thriftl.ll:155: error: ‘tok_xception’ was not declared in this scope
thriftl.ll:156: error: ‘tok_extends’ was not declared in this scope
thriftl.ll:157: error: ‘tok_throws’ was not declared in this scope
thriftl.ll:158: error: ‘tok_service’ was not declared in this scope
thriftl.ll:159: error: ‘tok_enum’ was not declared in this scope
thriftl.ll:160: error: ‘tok_const’ was not declared in this scope
thriftl.ll:161: error: ‘tok_required’ was not declared in this scope
thriftl.ll:162: error: ‘tok_optional’ was not declared in this scope
thriftl.ll:165: error: ‘tok_oneway’ was not declared in this scope
thriftl.ll:275: error: ‘yylval’ was not declared in this scope
thriftl.ll:279: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:284: error: ‘yylval’ was not declared in this scope
thriftl.ll:288: error: ‘tok_int_constant’ was not declared in this scope
thriftl.ll:292: error: ‘yylval’ was not declared in this scope
thriftl.ll:293: error: ‘tok_dub_constant’ was not declared in this scope
thriftl.ll:297: error: ‘yylval’ was not declared in this scope
thriftl.ll:298: error: ‘tok_identifier’ was not declared in this scope
thriftl.ll:302: error: ‘yylval’ was not declared in this scope
thriftl.ll:303: error: ‘tok_st_identifier’ was not declared in this scope
thriftl.ll:347: error: ‘yylval’ was not declared in this scope
thriftl.ll:348: error: ‘tok_literal’ was not declared in this scope
make[2]: *** [libparse_a-thriftl.o] Error 1
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1

我试过用谷歌搜索很多这些错误,但我不擅长 C++,也找不到任何帮助。

我需要做什么来修复这些错误?

4

2 回答 2

10

我相信你遇到了这里描述的错误: https ://issues.apache.org/jira/browse/THRIFT-1614 。

你可能有 automake-1.12(这是你会得到的brew install automake),它创建一个 thrifty.hh 文件而不是包含的 thrifty.h。错误报告中给出的解决方法是手动将包含更改thriftl.ccthrifty.hh. 如果您使用的是 brew,您也可以尝试降级 automake,应该会有所帮助。

于 2012-11-09T23:39:49.257 回答
0

出现此问题是因为 automake 生成文件“thrifty.hh”而不是“thrifty.h”。所以有两种方法可以解决这个问题。

1)将automake降级到1.11.5,然后修复;2) 编辑文件“thriftl.cc”,搜索“thrift.h”并将“thrifty.hh”替换为“thrifty.hh”,然后重新编译。

于 2017-04-17T08:23:17.760 回答