cocalele / PureFlash

A ServerSAN storage system designed for flash device
GNU General Public License v3.0
101 stars 29 forks source link

fail to compile on centos7 #6

Closed cocalele closed 4 years ago

cocalele commented 4 years ago

Zookeeper compile fail,

/home/lele/eclipse-workspace/PureFlash/build/../s5afs/thirdParty/zookeeper/zookeeper-client/zookeeper-client-c/tests/TestLogClientEnv.cc:38: undefined reference to `CppUnit::Message::Message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
s5afs/thirdParty/zookeeper/zookeeper-client/zookeeper-client-c/CMakeFiles/zktest.dir/tests/TestLogClientEnv.cc.o: In function `Zookeeper_logClientEnv::testLogClientEnv()':
/home/lele/eclipse-workspace/PureFlash/build/../s5afs/thirdParty/zookeeper/zookeeper-client/zookeeper-client-c/tests/TestLogClientEnv.cc:49: undefined reference to `CppUnit::SourceLine::SourceLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'

in fact I can find the symbol in file /usr/lib64/libcppunit-1.12.so

 objdump -TC /usr/lib64/libcppunit-1.12.so | grep CppUnit::SourceLine::SourceLine                                                                                            00000000000208c0 g    DF .text  0000000000000025  Base        CppUnit::SourceLine::SourceLine()
0000000000020950 g    DF .text  000000000000005a  Base        CppUnit::SourceLine::SourceLine(std::string const&, int)
00000000000208f0 g    DF .text  000000000000005f  Base        CppUnit::SourceLine::SourceLine(CppUnit::SourceLine const&)
00000000000208c0 g    DF .text  0000000000000025  Base        CppUnit::SourceLine::SourceLine()
0000000000020950 g    DF .text  000000000000005a  Base        CppUnit::SourceLine::SourceLine(std::string const&, int)
00000000000208f0 g    DF .text  000000000000005f  Base        CppUnit::SourceLine::SourceLine(CppUnit::SourceLine const&)
geekyang95 commented 4 years ago

Bug confirm, I'll fix it

geekyang95 commented 4 years ago

I can‘t reproduce this problem. enviroment:

OS: Centos 7.6 Compiler: g++ 4.8.5 Cppunit: cppunit-1.12.1-11 cmake version: cmake-3.6.2

This is a more common development environment for centos based developers. But I do find some compiler errors due to gcc 4.8, here is the fix: https://github.com/cocalele/PureFlash/pull/7

cocalele commented 4 years ago

Seems the problem of cppunit, version installed via rpm has different symbol than one compiled from source code. For example:

[lele@localhost lib]$ objdump -TC /usr/lib64/libcppunit-1.12.so.1.0.0 | grep CppUnit::Test::resolveTestPath 00000000000220e0 g DF .text 000000000000000e Base CppUnit::Test::resolveTestPath(std::string const&) const [lele@localhost lib]$ objdump -TC ~/Downloads/cppunit-1.12.1/src/cppunit/.libs/libcppunit-1.12.so.1.0.0 | grep CppUnit::Test::resolveTestPath 0000000000023830 g DF .text 0000000000000010 Base CppUnit::Test::resolveTestPath(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const

cocalele commented 4 years ago

replacing /usr/lib64/libcppunit-1.12.so.1.0.0 with myself compiled version solved this problem.

cppunit source code can be download from: https://jaist.dl.sourceforge.net/project/cppunit/cppunit/1.12.1/cppunit-1.12.1.tar.gz

cocalele commented 4 years ago

The root cause is ABI convention, as described at : https://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring/33395489#33395489