leveldb icon indicating copy to clipboard operation
leveldb copied to clipboard

check_library_exists cannot find snappy package correctly

Open ldeng-ustc opened this issue 1 year ago • 2 comments

I manually compiled and installed snappy 1.10 from source, then I tried to use cmake to compile levelDB, but it still prompted that it could not find snappy_compress, and compression would not be performed at runtime. The cmake prompt is as follows:

-- Looking for snappy_compress in snappy
-- Looking for snappy_compress in snappy - not found

If I manually modify CMakeLists.txt and set HAVE_SNAPPY on line 42 to ON, the compilation can succeed, and the compression function can run normally.

The following is the output in CMakeError.log (I don’t know if this is related to the problem):

Determining if the function snappy_compress exists in the snappy failed with the following output:
Change Dir: /home/ldeng/open-source/leveldb/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_b0e82/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_b0e82.dir/build.make CMakeFiles/cmTC_b0e82.dir/build
gmake[1]: Entering directory '/home/ldeng/open-source/leveldb/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_b0e82.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=snappy_compress -std=c11 -o CMakeFiles/cmTC_b0e82.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.22/Modules/CheckFunctionExists.c
Linking C executable cmTC_b0e82
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b0e82.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=snappy_compress CMakeFiles/cmTC_b0e82.dir/CheckFunctionExists.c.o -o cmTC_b0e82  -lsnappy 
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::WorkingMemory(unsigned long)':
snappy.cc:(.text+0x958): undefined reference to `std::allocator<char>::allocator()'
/usr/bin/ld: snappy.cc:(.text+0x987): undefined reference to `std::allocator<char>::~allocator()'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::~WorkingMemory()':
snappy.cc:(.text+0xa0d): undefined reference to `std::allocator<char>::allocator()'
/usr/bin/ld: snappy.cc:(.text+0xa37): undefined reference to `std::allocator<char>::~allocator()'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::Uncompress(char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
snappy.cc:(.text+0x206e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::max_size() const'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::Compress(char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
snappy.cc:(.text+0x2390): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::erase(unsigned long, unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::CompressFromIOVec(iovec const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
snappy.cc:(.text+0x246d): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::erase(unsigned long, unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::STLStringResizeUninitialized(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, unsigned long)':
snappy.cc:(.text._ZN6snappy28STLStringResizeUninitializedEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm[_ZN6snappy28STLStringResizeUninitializedEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm]+0x23): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::string_as_array(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
snappy.cc:(.text._ZN6snappy15string_as_arrayEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6snappy15string_as_arrayEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x27): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::empty() const'
/usr/bin/ld: snappy.cc:(.text._ZN6snappy15string_as_arrayEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6snappy15string_as_arrayEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x3e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::begin()'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::SnappySinkAllocator::Allocate(int)':
snappy.cc:(.text._ZN6snappy19SnappySinkAllocator8AllocateEi[_ZN6snappy19SnappySinkAllocator8AllocateEi]+0x32): undefined reference to `operator new[](unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::SnappySinkAllocator::Deleter(void*, char const*, unsigned long)':
snappy.cc:(.text._ZN6snappy19SnappySinkAllocator7DeleterEPvPKcm[_ZN6snappy19SnappySinkAllocator7DeleterEPvPKcm]+0x27): undefined reference to `operator delete[](void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIcE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIcE8allocateEmPKv]+0x39): undefined reference to `std::__throw_bad_alloc()'
/usr/bin/ld: snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIcE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIcE8allocateEmPKv]+0x45): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<char>::deallocate(char*, unsigned long)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIcE10deallocateEPcm[_ZN9__gnu_cxx13new_allocatorIcE10deallocateEPcm]+0x20): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `std::vector<snappy::SnappySinkAllocator::Datablock, std::allocator<snappy::SnappySinkAllocator::Datablock> >::_M_check_len(unsigned long, char const*) const':
snappy.cc:(.text._ZNKSt6vectorIN6snappy19SnappySinkAllocator9DatablockESaIS2_EE12_M_check_lenEmPKc[_ZNKSt6vectorIN6snappy19SnappySinkAllocator9DatablockESaIS2_EE12_M_check_lenEmPKc]+0x5f): undefined reference to `std::__throw_length_error(char const*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `std::pair<unsigned char const*, long> snappy::DecompressBranchless<char*>(unsigned char const*, unsigned char const*, long, char*, long)':
snappy.cc:(.text._ZN6snappy20DecompressBranchlessIPcEESt4pairIPKhlES4_S4_lT_l[_ZN6snappy20DecompressBranchlessIPcEESt4pairIPKhlES4_S4_lT_l]+0x4c8): undefined reference to `__cxa_guard_acquire'
/usr/bin/ld: snappy.cc:(.text._ZN6snappy20DecompressBranchlessIPcEESt4pairIPKhlES4_S4_lT_l[_ZN6snappy20DecompressBranchlessIPcEESt4pairIPKhlES4_S4_lT_l]+0x4fd): undefined reference to `__cxa_guard_release'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<snappy::SnappySinkAllocator::Datablock>::deallocate(snappy::SnappySinkAllocator::Datablock*, unsigned long)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE10deallocateEPS3_m[_ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE10deallocateEPS3_m]+0x20): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<snappy::SnappySinkAllocator::Datablock>::allocate(unsigned long, void const*)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv]+0x4e): undefined reference to `std::__throw_bad_alloc()'
/usr/bin/ld: snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIN6snappy19SnappySinkAllocator9DatablockEE8allocateEmPKv]+0x5e): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<char*>::deallocate(char**, unsigned long)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIPcE10deallocateEPS1_m[_ZN9__gnu_cxx13new_allocatorIPcE10deallocateEPS1_m]+0x20): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `std::vector<char*, std::allocator<char*> >::_M_check_len(unsigned long, char const*) const':
snappy.cc:(.text._ZNKSt6vectorIPcSaIS0_EE12_M_check_lenEmPKc[_ZNKSt6vectorIPcSaIS0_EE12_M_check_lenEmPKc]+0x5f): undefined reference to `std::__throw_length_error(char const*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `__gnu_cxx::new_allocator<char*>::allocate(unsigned long, void const*)':
snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv]+0x4e): undefined reference to `std::__throw_bad_alloc()'
/usr/bin/ld: snappy.cc:(.text._ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIPcE8allocateEmPKv]+0x5e): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy.cc.o): in function `snappy::SnappyIOVecReader::~SnappyIOVecReader()':
snappy.cc:(.text._ZN6snappy17SnappyIOVecReaderD0Ev[_ZN6snappy17SnappyIOVecReaderD5Ev]+0x24): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy-sinksource.cc.o): in function `snappy::Source::~Source()':
snappy-sinksource.cc:(.text+0x42): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy-sinksource.cc.o): in function `snappy::Sink::~Sink()':
snappy-sinksource.cc:(.text+0x8a): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy-sinksource.cc.o): in function `snappy::ByteArraySource::~ByteArraySource()':
snappy-sinksource.cc:(.text+0x18e): undefined reference to `operator delete(void*)'
/usr/bin/ld: /usr/local/lib/libsnappy.a(snappy-sinksource.cc.o): in function `snappy::UncheckedByteArraySink::~UncheckedByteArraySink()':
snappy-sinksource.cc:(.text+0x268): undefined reference to `operator delete(void*)'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_b0e82.dir/build.make:99: cmTC_b0e82] Error 1
gmake[1]: Leaving directory '/home/ldeng/open-source/leveldb/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_b0e82/fast] Error 2

ldeng-ustc avatar Sep 15 '23 08:09 ldeng-ustc