Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf版本问题导致的不能编译 #10

Closed
liu946 opened this issue Jul 26, 2018 · 25 comments
Closed

protobuf版本问题导致的不能编译 #10

liu946 opened this issue Jul 26, 2018 · 25 comments

Comments

@liu946
Copy link

liu946 commented Jul 26, 2018

编译 log 如下:
[ 4%] Built target extern_leveldb
[ 9%] Built target extern_jsoncpp
[ 13%] Built target extern_gtest
[ 18%] Built target extern_xgboost
[ 22%] Built target extern_eigen
[ 26%] Built target extern_paddle
[ 31%] Built target extern_curl
[ 35%] Built target extern_lac
[ 39%] Built target extern_boost
[ 43%] Built target extern_zlib
[ 47%] Built target extern_protobuf
[ 52%] Built target extern_gflags
[ 57%] Built target extern_openssl
[ 61%] Built target extern_glog
[ 61%] Performing install step for 'extern_brpc'
Compiling src/mcpack2pb/generator.o
In file included from src/mcpack2pb/generator.cpp:27:0:
./src/idl_options.pb.h:12:2: 错误:#error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
./src/idl_options.pb.h:13:2: 错误:#error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
./src/idl_options.pb.h:14:2: 错误:#error your headers.
#error your headers.
^
In file included from ./src/idl_options.pb.h:25:0,
from src/mcpack2pb/generator.cpp:27:
/usr/local/include/google/protobuf/generated_message_table_driven.h: 在函数‘bool google::protobuf::internal::ParseMap(google::protobuf::io::CodedInputStream*, void*)’中:
/usr/local/include/google/protobuf/generated_message_table_driven.h:185:20: 错误:expected nested-name-specifier before ‘MapEntryToMapField’
typedef typename MapEntryToMapField::MapFieldType MapFieldType;
^
/usr/local/include/google/protobuf/generated_message_table_driven.h:185:38: 错误:expected initializer before ‘<’ token
typedef typename MapEntryToMapField::MapFieldType MapFieldType;
^
/usr/local/include/google/protobuf/generated_message_table_driven.h:189:43: 错误:‘MapFieldType’在此作用域中尚未声明
typedef typename Entry::template Parser<MapFieldType, MapType> ParserType;
^
/usr/local/include/google/protobuf/generated_message_table_driven.h:191:33: 错误:expected type-specifier before ‘MapFieldType’
ParserType parser(static_cast<MapFieldType*>(map_field));
^
/usr/local/include/google/protobuf/generated_message_table_driven.h:191:33: 错误:expected ‘>’ before ‘MapFieldType’
/usr/local/include/google/protobuf/generated_message_table_driven.h:191:33: 错误:expected ‘(’ before ‘MapFieldType’
/usr/local/include/google/protobuf/generated_message_table_driven.h:191:46: 错误:expected primary-expression before ‘>’ token
ParserType parser(static_cast<MapFieldType*>(map_field));
^
In file included from ./src/idl_options.pb.h:27:0,
from src/mcpack2pb/generator.cpp:27:
/usr/local/include/google/protobuf/inlined_string_field.h: 在全局域:
/usr/local/include/google/protobuf/inlined_string_field.h:56:22: 错误:expected ‘;’ at end of member declaration
InlinedStringField()
^
/usr/local/include/google/protobuf/inlined_string_field.h:57:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:61:56: 错误:expected ‘;’ at end of member declaration
const InlinedStringField& from)
^
/usr/local/include/google/protobuf/inlined_string_field.h:62:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:64:69: 错误:expected ‘;’ at end of member declaration
void ClearToEmpty(const ::std::string* default_value, Arena* arena)
^
/usr/local/include/google/protobuf/inlined_string_field.h:65:7: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:68:31: 错误:expected ‘;’ at end of member declaration
void ClearNonDefaultToEmpty() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:68:33: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
void ClearNonDefaultToEmpty() GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:71:62: 错误:expected ‘;’ at end of member declaration
void ClearToEmptyNoArena(const ::std::string* default_value)
^
/usr/local/include/google/protobuf/inlined_string_field.h:72:7: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:75:38: 错误:expected ‘;’ at end of member declaration
void ClearNonDefaultToEmptyNoArena()
^
/usr/local/include/google/protobuf/inlined_string_field.h:76:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:78:71: 错误:expected ‘;’ at end of member declaration
void ClearToDefault(const ::std::string* default_value, Arena* arena)
^
/usr/local/include/google/protobuf/inlined_string_field.h:79:7: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:82:64: 错误:expected ‘;’ at end of member declaration
void ClearToDefaultNoArena(const ::std::string* default_value)
^
/usr/local/include/google/protobuf/inlined_string_field.h:83:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:85:64: 错误:expected ‘;’ at end of member declaration
void Destroy(const ::std::string* default_value, Arena* arena)
^
/usr/local/include/google/protobuf/inlined_string_field.h:86:7: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:89:57: 错误:expected ‘;’ at end of member declaration
void DestroyNoArena(const ::std::string* default_value)
^
/usr/local/include/google/protobuf/inlined_string_field.h:90:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:92:30: 错误:expected ‘;’ at end of member declaration
const ::std::string& Get() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:92:36: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
const ::std::string& Get() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:95:37: 错误:expected ‘;’ at end of member declaration
const ::std::string& GetNoArena() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:95:43: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
const ::std::string& GetNoArena() const GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:97:74: 错误:expected ‘;’ at end of member declaration
::std::string* Mutable(const ::std::string* default_value, Arena* arena)
^
/usr/local/include/google/protobuf/inlined_string_field.h:98:7: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:101:67: 错误:expected ‘;’ at end of member declaration
::std::string* MutableNoArena(const ::std::string* default_value)
^
/usr/local/include/google/protobuf/inlined_string_field.h:102:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:117:24: 错误:expected ‘;’ at end of member declaration
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:117:26: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:122:28: 错误:expected ‘;’ at end of member declaration
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:122:30: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:126:36: 错误:expected ‘;’ at end of member declaration
StringPiece value) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:126:38: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
StringPiece value) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:130:24: 错误:expected ‘;’ at end of member declaration
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:130:26: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:135:28: 错误:expected ‘;’ at end of member declaration
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:135:30: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
Arena* arena) GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE {
^
/usr/local/include/google/protobuf/inlined_string_field.h:139:45: 错误:expected ‘;’ at end of member declaration
const ::std::string& value)
^
/usr/local/include/google/protobuf/inlined_string_field.h:140:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
/usr/local/include/google/protobuf/inlined_string_field.h:154:37: 错误:expected ‘;’ at end of member declaration
void Swap(InlinedStringField* from)
^
/usr/local/include/google/protobuf/inlined_string_field.h:155:5: 错误:‘GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE’不是一个类型名
GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE;
^
In file included from src/mcpack2pb/generator.cpp:27:0:
./src/idl_options.pb.h:42:16: 错误:‘FieldMetadata’不是命名空间‘google::protobuf::internal’中的一个类型名
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
^
./src/idl_options.pb.h:43:16: 错误:‘SerializationTable’不是命名空间‘google::protobuf::internal’中的一个类型名
static const ::google::protobuf::internal::SerializationTable serialization_table[];
^
make[3]: *** [src/mcpack2pb/generator.o] 错误 1
make[2]: *** [third_party/brpc/src/extern_brpc-stamp/extern_brpc-install] 错误 2
make[1]: *** [CMakeFiles/extern_brpc.dir/all] 错误 2
make: *** [all] 错误 2

@liu946
Copy link
Author

liu946 commented Jul 26, 2018

希望能帮忙解决一下编译问题,protobuf是https://github.com/google/protobuf/tree/3.6.x 源码编译安装的。
protoc --version
libprotoc 2.5.0

@zhanghan1992
Copy link
Collaborator

跟系统默认的protobuf冲突了
rm -rf path-of-anyq/build/third_party/brpc
export PATH= path-of-anyq/build/third_party/bin:$PATH
make

@liu946
Copy link
Author

liu946 commented Jul 27, 2018

非常感谢 @zhanghan1992 ,不过又出现了连接问题,请您帮忙解决一下,麻烦了,多谢。

....
[100%] Linking CXX executable run_server
third_party/lib/libleveldb.a(table_builder.o):在函数‘leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*)’中:
table_builder.cc:(.text+0x93f):对‘snappy::MaxCompressedLength(unsigned long)’未定义的引用
table_builder.cc:(.text+0x97d):对‘snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)’未定义的引用
third_party/lib/libleveldb.a(format.o):在函数‘leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)’中:
format.cc:(.text+0x4d9):对‘snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)’未定义的引用
format.cc:(.text+0x5ae):对‘snappy::RawUncompress(char const*, unsigned long, char*)’未定义的引用
collect2: 错误:ld 返回 1
make[2]: *** [run_server] 错误 1
make[1]: *** [CMakeFiles/run_server.dir/all] 错误 2
make: *** [all] 错误 2

@zhanghan1992
Copy link
Collaborator

这里出错的原因是在安装leveldb的时候,在你的环境里找到了snappy.h的头文件,但没有找到libsnappy.a。

  1. 编译安装snappy,把libsnappy.a的路径加到环境变量LIBRARY_PATH里
  2. 看一下path-of-anyq/build/third_party/leveldb/src/leveldb/build_config.mk文件,如果PLATFORM_LIBS变量里已经包含lsnappy,直接执行'make'继续编译就可以;否则需要 ‘rm -rf path-of-anyq/build/third_party/leveldb path-of-anyq/build/third_party/brpc',然后执行'make'

@liu946
Copy link
Author

liu946 commented Jul 27, 2018

还是有点问题,麻烦您再帮忙看一下:

  • build_config.mk 文件
> cat third_party/leveldb/src/leveldb/build_config.mk
SOURCES=db/builder.cc db/c.cc db/dbformat.cc db/db_impl.cc db/db_iter.cc db/dumpfile.cc db/filename.cc db/log_reader.cc db/log_writer.cc db/memtable.cc db/repair.cc db/table_cache.cc db/version_edit.cc db/version_set.cc db/write_batch.cc table/block_builder.cc table/block.cc table/filter_block.cc table/format.cc table/iterator.cc table/merger.cc table/table_builder.cc table/table.cc table/two_level_iterator.cc util/arena.cc util/bloom.cc util/cache.cc util/coding.cc util/comparator.cc util/crc32c.cc util/env.cc util/env_posix.cc util/filter_policy.cc util/hash.cc util/histogram.cc util/logging.cc util/options.cc util/status.cc  port/port_posix.cc port/port_posix_sse.cc
MEMENV_SOURCES=helpers/memenv/memenv.cc
CC=cc
CXX=g++
PLATFORM=OS_LINUX
PLATFORM_LDFLAGS=-pthread
PLATFORM_LIBS= -lsnappy
PLATFORM_CCFLAGS= -fno-builtin-memcmp -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT -DSNAPPY
PLATFORM_CXXFLAGS=-std=c++0x -fno-builtin-memcmp -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT -DSNAPPY
PLATFORM_SSEFLAGS=-msse4.2 -DLEVELDB_PLATFORM_POSIX_SSE
PLATFORM_SHARED_CFLAGS=-fPIC
PLATFORM_SHARED_EXT=so
PLATFORM_SHARED_LDFLAGS=-shared -Wl,-soname -Wl,
PLATFORM_SHARED_VERSIONED=true
  • snappy(yum安装)位置及环境变量
➜  build git:(master) ✗ ls /usr/local/lib64 | grep snappy
libsnappy.a
➜  build git:(master) ✗ echo $LIBRARY_PATH
/usr/lib64:/usr/local/lib64
  • make报错
[100%] Linking CXX executable run_server
third_party/lib/libleveldb.a(table_builder.o):在函数‘leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*)’中:
table_builder.cc:(.text+0x93f):对‘snappy::MaxCompressedLength(unsigned long)’未定义的引用
table_builder.cc:(.text+0x97d):对‘snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)’未定义的引用
third_party/lib/libleveldb.a(format.o):在函数‘leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)’中:
format.cc:(.text+0x4d9):对‘snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)’未定义的引用
format.cc:(.text+0x5ae):对‘snappy::RawUncompress(char const*, unsigned long, char*)’未定义的引用
collect2: 错误:ld 返回 1
make[2]: *** [run_server] 错误 1
make[1]: *** [CMakeFiles/run_server.dir/all] 错误 2
make: *** [all] 错误 2

@zhanghan1992
Copy link
Collaborator

1."strings usr/local/lib64/libsnappy.a | grep RawCompress",检查链接不上的符号是否在这个版本的lib里; 检查是否存在usr/lib64/libsnappy.a。存在的话用上面的方法检查/usr/lib64/libsnappy.a。编译时优先从LIBRARY_PATH中写在前面的路径中找lib。
2. 如果上面的检查没问题的话,‘rm -rf path-of-anyq/build/third_party/leveldb path-of-anyq/build/third_party/brpc',然后执行"make"

@liu946
Copy link
Author

liu946 commented Jul 30, 2018

非常感谢,按照您的方法检查之后报错如下:

➜  build git:(master) ✗ strings /usr/local/lib64/libsnappy.a | grep RawCompress
_ZN6snappy11RawCompressEPKcmPcPm
_ZN6snappy11RawCompressEPKcmPcPm
_ZN6snappy11RawCompressEPKcmPcPm
➜  build git:(master) ✗ string /usr/lib64/libsnappy.a | grep RawCompress
zsh: string: 未找到命令...
zsh: command not found: string
➜  build git:(master) ✗ strings /usr/lib64/libsnappy.a | grep RawCompress
strings: /usr/lib64/libsnappy.a:无此文件
➜  build git:(master) ✗ rm -fr third_party/leveldb third_party/brpc
➜  build git:(master) ✗ make
-- Configuring done
-- Generating done
-- Build files have been written to: /data/home/liuyang/AnyQ/build
[  1%] Creating directories for 'extern_leveldb'
[  1%] Performing download step for 'extern_leveldb'
正克隆到 'leveldb'...
remote: Counting objects: 2029, done.
remote: Total 2029 (delta 0), reused 0 (delta 0), pack-reused 2029
接收对象中: 100% (2029/2029), 1.13 MiB | 260.00 KiB/s, done.
处理 delta 中: 100% (1369/1369), done.
Note: checking out 'v1.20'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD 目前位于 a53934a... Increase leveldb version to 1.20.
[  1%] No patch step for 'extern_leveldb'
[  2%] No update step for 'extern_leveldb'
[  3%] No configure step for 'extern_leveldb'
[  3%] No build step for 'extern_leveldb'
[  4%] Performing install step for 'extern_leveldb'
/usr/bin/ld: /usr/local/lib64/../lib64/libsnappy.a(snappy.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib64/../lib64/libsnappy.a(snappy-sinksource.cc.o): relocation R_X86_64_32S against symbol `_ZTVN6snappy6SourceE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: 输出不可表示的节
collect2: 错误:ld 返回 1
make[3]: *** [out-shared/libleveldb.so.1.20] 错误 1
make[2]: *** [third_party/leveldb/src/extern_leveldb-stamp/extern_leveldb-install] 错误 2
make[1]: *** [CMakeFiles/extern_leveldb.dir/all] 错误 2
make: *** [all] 错误 2

@zhanghan1992
Copy link
Collaborator

export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
然后重新编译安装snappy

@liu946
Copy link
Author

liu946 commented Jul 30, 2018

重新编译后还是出现了之前的报错信息,已经用strings检查过变量名,存在 /usr/local/lib64/libsnappy.a中,报错信息如下:

[100%] Linking CXX executable run_server
third_party/lib/libleveldb.a(table_builder.o):在函数‘leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*)’中:
table_builder.cc:(.text+0x93f):对‘snappy::MaxCompressedLength(unsigned long)’未定义的引用
table_builder.cc:(.text+0x97d):对‘snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)’未定义的引用
third_party/lib/libleveldb.a(format.o):在函数‘leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)’中:
format.cc:(.text+0x4d9):对‘snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)’未定义的引用
format.cc:(.text+0x5ae):对‘snappy::RawUncompress(char const*, unsigned long, char*)’未定义的引用
collect2: 错误:ld 返回 1
make[2]: *** [run_server] 错误 1
make[1]: *** [CMakeFiles/run_server.dir/all] 错误 2
make: *** [all] 错误 2

@zhanghan1992
Copy link
Collaborator

你可以先把环境里的snappy.h删掉,然后删除leveldb后重新编译 。编译leveldb时如果在环境里找不到snappy.h会编译不依赖snappy的版本。

@liu946
Copy link
Author

liu946 commented Jul 30, 2018

解决了,多谢

@liu946 liu946 closed this as completed Jul 30, 2018
@zhongyunuestc
Copy link

config_brpc.sh: 32: config_brpc.sh: realpath: not found
config_brpc.sh: 33: config_brpc.sh: realpath: not found
config_brpc: --headers=HDRPATHS --libs=LIBPATHS must be specified
make[2]: *** [third_party/brpc/src/extern_brpc-stamp/extern_brpc-install] 错误 1
make[1]: *** [CMakeFiles/extern_brpc.dir/all] 错误 2

您好,我也遇到了同样的问题,按照你说的这个方法弄了还是一样的错误,是什么原因呢,谢谢:
跟系统默认的protobuf冲突了
rm -rf path-of-anyq/build/third_party/brpc
export PATH= path-of-anyq/build/third_party/bin:$PATH
make

@zhanghan1992
Copy link
Collaborator

@zhongyunuestc
环境里缺少realpath指令,需要安装realpath。

@zhongyunuestc
Copy link

zhongyunuestc commented Aug 14, 2018 via email

@YiLing28
Copy link

[ 98%] Linking CXX executable run_server
third_party/lib/libleveldb.a(table_builder.o): In function leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*)': table_builder.cc:(.text+0x96f): undefined reference to snappy::MaxCompressedLength(unsigned long)'
table_builder.cc:(.text+0x9ad): undefined reference to snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)' third_party/lib/libleveldb.a(format.o): In function leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)':
format.cc:(.text+0x4d9): undefined reference to snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)' format.cc:(.text+0x5ae): undefined reference to snappy::RawUncompress(char const*, unsigned long, char*)'
collect2: error: ld returned 1 exit status
make[2]: *** [run_server] Error 1
make[1]: *** [CMakeFiles/run_server.dir/all] Error 2
make: *** [all] Error 2

你好,请问你是怎么删除你环境里的snappy.h呢(怎么找到这个在哪个环境变量下面)

@zhanghan1992
Copy link
Collaborator

@lingdavid

whereis snappy.h

@YiLing28
Copy link

@zhanghan1992
十分感谢

@YiLing28
Copy link

你好,请问一下,在./run_server之后出现以下内容:
Loaded q2b dic -- num = 172
Loaded strong punc -- num = 5
Loaded word dic -- num(with oov) = 20940
Loaded tag dic -- num = 57
WARNING: Logging before InitGoogleLogging() is written to STDERR
W1023 15:57:19.929847 4083 init.cc:85] 'CUDA' is not supported, Please re-compile with WITH_GPU option
W1023 15:57:19.929895 4083 init.cc:101] 'CUDA' is not supported, Please re-compile with WITH_GPU option
Segmentation fault (core dumped)
这是什么问题啊

@zhanghan1992
Copy link
Collaborator

zhanghan1992 commented Oct 23, 2018

@lingdavid
用gdb看一下core, 查一下挂在哪里

@YiLing28
Copy link

core: No such file or directory
没产生core文件

@zhanghan1992
Copy link
Collaborator

@lingdavid

ulimit -c unlimited

@YiLing28
Copy link

Core was generated by `./run_server'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f3465c83923 in paddle::framework::Executor::CreateVariables(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
(gdb) bt
#0 0x00007f3465c83923 in paddle::framework::Executor::CreateVariables(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
#1 0x00007f3465c83fa9 in paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
#2 0x00007f3465c84d80 in paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
#3 0x00007f3465c23a6f in paddle::inference::LoadPersistables(paddle::framework::Executor*, paddle::framework::Scope*, paddle::framework::ProgramDesc const&, std::string const&, std::string const&) ()
from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
#4 0x00007f3465c2497d in paddle::inference::Load(paddle::framework::Executor*, paddle::framework::Scope*, std::string const&) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so
#5 0x000000000083e583 in lac::MainTagger::init_model (this=this@entry=0x40b07a0, model_path="./example/conf/./wordseg_utf8/model/") at /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lac/src/lac/src/main_tagger.cpp:261
#6 0x000000000083ec9a in lac::MainTagger::create (conf_dir=conf_dir@entry=0x40aea98 "./example/conf/./wordseg_utf8") at /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lac/src/lac/src/main_tagger.cpp:79
#7 0x0000000000836a31 in lac::Lac::create (conf_dir=0x40aea98 "./example/conf/./wordseg_utf8") at /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lac/src/lac/src/lac.cpp:69
#8 0x0000000000833cfb in lac_create (conf_dir=) at /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lac/src/lac/src/ilac.cpp:24
#9 0x00000000007cf2d6 in anyq::WordsegAdapter::load (this=0x40aeaf0, path="./example/conf/./wordseg_utf8", config=...) at /home/ldw/work/Chat_QA/AnyQ-master/src/dict/wordseg_adapter.cpp:29
#10 0x00000000007ccf64 in anyq::DualDictWrapper::reload (this=0x40ae990) at /home/ldw/work/Chat_QA/AnyQ-master/src/dict/dual_dict_wrapper.cpp:72
#11 0x0000000000826a03 in anyq::DictManager::load_dict (this=0x7fff00a22518, conf_path="./example/conf/") at /home/ldw/work/Chat_QA/AnyQ-master/src/dict/dict_manager.cpp:51
#12 0x00000000007e94ec in anyq::HttpServer::init (this=0x7fff00a22480, http_server_conf="./example/conf/anyq_brpc.conf") at /home/ldw/work/Chat_QA/AnyQ-master/src/server/http_server.cpp:52
#13 0x000000000079d5b8 in main (argc=1, argv=0x7fff00a22b58) at /home/ldw/work/Chat_QA/AnyQ-master/demo/run_server.cpp:25

@YiLing28
Copy link

@zhanghan1992
gdb ./run_server core
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./run_server...done.

warning: exec file is newer than core file.
[New LWP 10062]
[New LWP 10063]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./run_server'.
Program terminated with signal SIGSEGV, Segmentation fault.
_#0 0x00007f3465c83923 in paddle::framework::Executor::CreateVariables(paddle::framework::ProgramDesc const&, paddle::framework::Scope, int) () from /home/ldw/work/Chat_QA/AnyQ-master/build/third_party/lib/libpaddle_fluid.so_*
(gdb) list
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <glog/logging.h>
16 #include "server/http_server.h"
17 #include "common/utils.h"
18 #include "common/plugin_header.h"
19
20 int main(int argc, char* argv[]) {

@tony-j-shao
Copy link

tony-j-shao commented Oct 26, 2018

您好,

我在编译过程中也遇到了liu946类似的protobuf的问题,不过我的protocol版本已经是最新,也试过了提供的解决方法,还是会报错:

protoc --version
libprotoc 3.6.1

我是Ubuntu 16.04, Cuda 9.0 ,Python2.7 tensorflow-gpu 1.5.0

编译错误代码:
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:279:31: error: expected ‘,’ or ‘...’ before string constant
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:281:24: error: ISO C++ forbids declaration of ‘PROTOBUF_RUNTIME_DEPRECATED’ with no type [-fpermissive]
" future release.")
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:281:24: error: expected ‘;’ at end of member declaration
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:279:3: error: ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’ cannot be overloaded
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:206:3: error: with ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:298:31: error: expected identifier before string constant
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:298:31: error: expected ‘,’ or ‘...’ before string constant
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:300:24: error: ISO C++ forbids declaration of ‘PROTOBUF_RUNTIME_DEPRECATED’ with no type [-fpermissive]
" future release.")
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:300:24: error: expected ‘;’ at end of member declaration
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:298:3: error: ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’ cannot be overloaded
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:206:3: error: with ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:302:31: error: expected identifier before string constant
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:302:31: error: expected ‘,’ or ‘...’ before string constant
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:304:24: error: ISO C++ forbids declaration of ‘PROTOBUF_RUNTIME_DEPRECATED’ with no type [-fpermissive]
" future release.")
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:304:24: error: expected ‘;’ at end of member declaration
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:302:3: error: ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’ cannot be overloaded
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:206:3: error: with ‘int tensorflow::OpDef_ArgDef::PROTOBUF_RUNTIME_DEPRECATED(int)’
PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:324:65: error: ‘InternalHelper’ in ‘class google::protobuf::Arena’ does not name a type
template friend class ::google::protobuf::Arena::InternalHelper;
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:366:48: error: expected ‘;’ at end of member declaration
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:366:54: error: ‘PROTOBUF_FINAL’ does not name a type
inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:369:39: error: expected ‘;’ at end of member declaration
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:369:45: error: ‘PROTOBUF_FINAL’ does not name a type
inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:380:10: error: ‘PROTOBUF_CONSTEXPR’ does not name a type
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:391:31: error: expected ‘;’ at end of member declaration
inline OpDef_AttrDef* New() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:391:37: error: ‘PROTOBUF_FINAL’ does not name a type
inline OpDef_AttrDef* New() const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:395:56: error: expected ‘;’ at end of member declaration
OpDef_AttrDef* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:395:62: error: ‘PROTOBUF_FINAL’ does not name a type
OpDef_AttrDef* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL {
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:398:56: error: expected ‘;’ at end of member declaration
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:398:58: error: ‘PROTOBUF_FINAL’ does not name a type
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:399:57: error: expected ‘;’ at end of member declaration
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
^
/home/shao/AnyQ/build/third_party/include/tf/tensorflow/core/framework/op_def.pb.h:399:59: error: ‘PROTOBUF_FINAL’ does not name a type
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
^

@ganguagua
Copy link

ganguagua commented Apr 15, 2019

跟系统默认的protobuf冲突了
rm -rf path-of-anyq/build/third_party/brpc
export PATH= path-of-anyq/build/third_party/bin:$PATH
make

我这样做了之后还是显示protoc版本低了,tensorflow是1.8.0的包
protoc --version
libprotoc 3.1.0

/mnt/disk1/home/ganshijie/AnyQ_tf/build/third_party/include/tf/tensorflow/core/framework/device_attributes.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
/mnt/disk1/home/ganshijie/AnyQ_tf/build/third_party/include/tf/tensorflow/core/framework/device_attributes.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
/mnt/disk1/home/ganshijie/AnyQ_tf/build/third_party/include/tf/tensorflow/core/framework/device_attributes.pb.h:14:2: error: #error your headers.
#error your headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants