Kegem0 commented on issue #2356: URL: https://github.com/apache/brpc/issues/2356#issuecomment-1675191511
继续做一个排列组合,我在自己的机器上,用centos默认yum install下载的依赖,并且直接将gcc升级到8.3.0,clean之后重新make,弹出来的错误是protobuf和gflags的undefined reference的问题,截取一段如下: /home/ym/apache-brpc-1.6.0-src/src/bvar/variable.cpp:920: undefined reference to `gflags::RegisterFlagValidator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, bool (*)(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))' libbrpc.a(variable.o):/home/ym/apache-brpc-1.6.0-src/src/bvar/variable.cpp:925: more undefined references to `gflags::RegisterFlagValidator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, bool (*)(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))' follow libbrpc.a(gflag.o): In function `bvar::GFlag::get_value[abi:cxx11]() const': /home/ym/apache-brpc-1.6.0-src/src/bvar/gflag.cpp:81: undefined reference to `gflags::GetCommandLineOption(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' libbrpc.a(gflag.o): In function `bvar::GFlag::set_value(char const*)': /home/ym/apache-brpc-1.6.0-src/src/bvar/gflag.cpp:88: undefined reference to `gflags::SetCommandLineOption[abi:cxx11](char const*, char const*)' /home/ym/apache-brpc-1.6.0-src/src/bvar/variable.cpp:920: undefined reference to `gflags::RegisterFlagValidator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, bool (*)(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))' libbrpc.a(variable.o):/home/ym/apache-brpc-1.6.0-src/src/bvar/variable.cpp:925: more undefined references to `gflags::RegisterFlagValidator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, bool (*)(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))' follow libbrpc.a(gflag.o): In function `bvar::GFlag::get_value[abi:cxx11]() const': /home/ym/apache-brpc-1.6.0-src/src/bvar/gflag.cpp:81: undefined reference to `gflags::GetCommandLineOption(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' libbrpc.a(gflag.o): In function `bvar::GFlag::set_value(char const*)': /home/ym/apache-brpc-1.6.0-src/src/bvar/gflag.cpp:88: undefined reference to `gflags::SetCommandLineOption[abi:cxx11](char const*, char const*)' 这个我在社区好像看到过,是 我在Makefile中加上了这一句 -D_GLIBCXX_USE_CXX11_ABI=0(CXXFLAGS或者CPPFLAGS后应该都行)最后编译成功。不过似乎-D_GLIBCXX_USE_CXX11_ABI=0这个行为并不好,高版本之所以将其抛弃也是其不安全性。这里属于是对编译成功的一种妥协了。 然后尝试编译这个简单样例 ```shell cd example/echo_c++ make ``` make的时候依然报类似的错误: /home/ym/apache-brpc-1.6.0-src/example/echo_c++/../../output/include/butil/class_name.h:35: undefined reference to `butil::demangle[abi:cxx11](char const*)' /home/ym/apache-brpc-1.6.0-src/example/echo_c++/../../output/include/butil/class_name.h:35: undefined reference to `butil::demangle[abi:cxx11](char const*)' /home/ym/apache-brpc-1.6.0-src/example/echo_c++/../../output/include/butil/class_name.h:35: undefined reference to `butil::demangle[abi:cxx11](char const*)' server.o: In function `__static_initialization_and_destruction_1': /home/ym/apache-brpc-1.6.0-src/example/echo_c++/../../output/include/butil/class_name.h:35: undefined reference to `butil::demangle[abi:cxx11](char const*)' 当然是同样的操作(ABI=0),这里就发现这种方式很不方便了,yum install默认下载的包都是旧的GCC版本编译的,而我们现在用旧的GCC版本没法编译brpc(而这个问题又仅仅出现在centos上,我的unbuntu系统又运行正常),这就产生了冲突。然后编译通过,执行样例 ```shell ./echo_server & ./echo_client ``` 当然不会成功,报错如下 ./echo_server: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.23' not found (required by ./echo_server) ./echo_server: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./echo_server) ./echo_server: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./echo_server) ./echo_server: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./echo_server) 看起来它还是找的系统默认路径下libstdc++.so.6,为了维护我把gcc8.3.0下载到了/usr/local/gcc8.3.0,不过估计我下到/usr/local也没用,他又不会覆盖掉默认路径。 我把我的gcc8.3.0下的lib64的libstdc++.so.6拷贝到了默认路径下/usr/lib64,之后运行成功,取得阶段性胜利了属于是。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org