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

CentOS7 编译失败 #2568

Closed
howz97 opened this issue Mar 13, 2024 · 10 comments
Closed

CentOS7 编译失败 #2568

howz97 opened this issue Mar 13, 2024 · 10 comments

Comments

@howz97
Copy link

howz97 commented Mar 13, 2024

Describe the bug (描述bug)
CentOS7 编译失败

To Reproduce (复现方法)
根据文档在CentOS7执行:

sudo yum install epel-release
sudo yum install git gcc-c++ make openssl-devel gflags-devel protobuf-devel protobuf-compiler leveldb-devel
$ sh config_brpc.sh --headers="/usr/include" --libs="/usr/lib64 /usr/bin"
$ make

得到结果

> Generating src/idl_options.pb.cc
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/idl_options.proto
g++ -c -I./src -I/usr/include/ -std=c++0x -DBRPC_WITH_GLOG=0 -DGFLAGS_NS=gflags -D__const__=__unused__ -g -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"1.8.0\|master\|37814d2\|2024-03-13T13:31:41+08:00\" -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer src/mcpack2pb/generator.cpp -o src/mcpack2pb/generator.o
> Generating src/brpc/rtmp.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/rtmp.proto
> Generating src/brpc/get_favicon.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/get_favicon.proto
> Generating src/brpc/get_js.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/get_js.proto
> Generating src/brpc/span.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/span.proto
> Generating src/brpc/streaming_rpc_meta.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/streaming_rpc_meta.proto
> Generating src/brpc/builtin_service.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/builtin_service.proto
> Generating src/brpc/grpc_health_check.pb.h
/usr/bin/protoc --cpp_out=./src --proto_path=./src --proto_path=/usr/include/ src/brpc/grpc_health_check.proto
brpc/grpc_health_check.proto:39:51: Expected ")".
make: *** [src/brpc/grpc_health_check.pb.h] Error 1

Expected behavior (期望行为)

编译通过
Versions (各种版本)
OS: CentOS7
Compiler: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
brpc: 37814d2
protobuf:

Additional context/screenshots (更多上下文/截图)

尝试用cmake 进行编译:

mkdir build && cd build 
cmake ..

仍然编译失败:

-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found gflags: /usr/lib64/libgflags.so
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found PROTOBUF: /usr/lib64/libprotobuf.so
CMake Error at CMakeLists.txt:157 (if):
  if given arguments:

    "Protobuf_VERSION" "GREATER_EQUAL" "4.22"

  Unknown arguments specified


-- Configuring incomplete, errors occurred!
See also "/home/centos/brpc/build/CMakeFiles/CMakeOutput.log".
See also "/home/centos/brpc/build/CMakeFiles/CMakeError.log".
@wasphin
Copy link
Member

wasphin commented Mar 13, 2024

可以先试下 cmake3,稍后修复。

@wasphin
Copy link
Member

wasphin commented Mar 13, 2024

@howz97 辛苦试下这个吧

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9df7f1ef..6af29dc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,7 +154,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 endif()

 find_package(Protobuf REQUIRED)
-if(Protobuf_VERSION GREATER_EQUAL 4.22)
+if(Protobuf_VERSION GREATER 4.21)
     # required by absl
     set(CMAKE_CXX_STANDARD 17)

@wasphin
Copy link
Member

wasphin commented Mar 13, 2024

另外依赖 protobuf 3, centos 自带的 protobuf 2.5 在 1.8.0 下无法编译了

#2493 以及 #2406 中引入了两个 protobuf 3 的语法

wasphin added a commit that referenced this issue Mar 13, 2024
`GREATER_EQUAL` was introduced since cmake 3.7

Related to #2568
@howz97
Copy link
Author

howz97 commented Mar 14, 2024

感谢回复。

除了 cmake3 , protobuf3 ,还要升级到gcc8,brpc就编译过了。

编译example/redis_c++ 时 还需要 yum install readline-devel 。然后把代码google::ParseCommandLineFlags改成gflags::ParseCommandLineFlags

@howz97 howz97 closed this as completed Mar 22, 2024
@missximon
Copy link

对应README中是不是也需要修改一下,要求protobuf 3+了,README还是写的protobuf2.4+即可...

@IronsDu
Copy link

IronsDu commented Apr 9, 2024

感谢回复。

除了 cmake3 , protobuf3 ,还要升级到gcc8,brpc就编译过了。

编译example/redis_c++ 时 还需要 yum install readline-devel 。然后把代码google::ParseCommandLineFlags改成gflags::ParseCommandLineFlags

brpc的最低要求是gcc8么?

@wasphin
Copy link
Member

wasphin commented Apr 11, 2024

对应README中是不是也需要修改一下,要求protobuf 3+了,README还是写的protobuf2.4+即可...

现在由于引入了部分 protobuf 3 语法导致依赖 3.0+, 同时由于 protobuf 接口变更导致不兼容 3.6+, 所以最新的 protobuf 兼容的版本就是 3.0~3.25 了. 后面看下 protobuf 这部分怎么兼容比较好.

@wasphin
Copy link
Member

wasphin commented Apr 11, 2024

感谢回复。
除了 cmake3 , protobuf3 ,还要升级到gcc8,brpc就编译过了。
编译example/redis_c++ 时 还需要 yum install readline-devel 。然后把代码google::ParseCommandLineFlags改成gflags::ParseCommandLineFlags

brpc的最低要求是gcc8么?

老版本编译器对部分模版兼容比较差,编译有问题,gcc-8 测试是没问题的,最低哪个版本可以还没测试过。

@dengyingxu
Copy link

请问,哪个版本可以用protobuf 2.5? 我只用bvar做监控上报,不需要新功能呢

@wasphin
Copy link
Member

wasphin commented Sep 5, 2024

请问,哪个版本可以用protobuf 2.5? 我只用bvar做监控上报,不需要新功能呢

可以试下 1.5

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

5 participants