我试图在mac os x high sierra上构建https://github.com/google/leveldb支持https://github.com/google/snappy压缩,以便以后在XCode项目中使用,我正在完成标准编译过程两个项目的自述文件。这包括通过cmake
为两个项目构建项目。在snappy
项目的情况下,程序很顺利,所有内容都可以完美地构建和安装。但是,如果是leveldb
,我无法cmake
找到我之前通过snappy
安装的make install
库。我不了解如何调试cmake
并找到它寻找图书馆的地方。
感谢任何帮助。
修改
这是一个输出,似乎/ usr / local / lib在列表中
其他编辑
我已根据cc -DCHECK_FUNCTION_EXISTS=snappy_compress -Wl,-search_paths_first -Wl,-headerpad_max_install_names -o check_snappy_exist CheckFunctionExists.c -lsnappy
提供的解决方案尝试运行sel-fish
。但如果输出失败,则输出:
Undefined symbols for architecture x86_64:
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"std::logic_error::logic_error(char const*)", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"std::length_error::~length_error()", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::resize(unsigned long, char)", referenced from:
snappy::Uncompress(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in libsnappy.a(snappy.cc.o)
snappy::Compress(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in libsnappy.a(snappy.cc.o)
"std::terminate()", referenced from:
___clang_call_terminate in libsnappy.a(snappy.cc.o)
"typeinfo for std::length_error", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for snappy::Sink in libsnappy.a(snappy-sinksource.cc.o)
typeinfo for snappy::Source in libsnappy.a(snappy-sinksource.cc.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
typeinfo for snappy::ByteArraySource in libsnappy.a(snappy-sinksource.cc.o)
typeinfo for snappy::UncheckedByteArraySink in libsnappy.a(snappy-sinksource.cc.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::length_error", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"operator delete[](void*)", referenced from:
snappy::Compress(snappy::Source*, snappy::Sink*) in libsnappy.a(snappy.cc.o)
snappy::SnappySinkAllocator::Deleter(void*, char const*, unsigned long) in libsnappy.a(snappy.cc.o)
"operator delete(void*)", referenced from:
snappy::UncompressAsMuchAsPossible(snappy::Source*, snappy::Sink*) in libsnappy.a(snappy.cc.o)
snappy::Uncompress(snappy::Source*, snappy::Sink*) in libsnappy.a(snappy.cc.o)
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
snappy::ByteArraySource::~ByteArraySource() in libsnappy.a(snappy-sinksource.cc.o)
snappy::UncheckedByteArraySink::~UncheckedByteArraySink() in libsnappy.a(snappy-sinksource.cc.o)
"operator new[](unsigned long)", referenced from:
snappy::internal::WorkingMemory::GetHashTable(unsigned long, int*) in libsnappy.a(snappy.cc.o)
snappy::Compress(snappy::Source*, snappy::Sink*) in libsnappy.a(snappy.cc.o)
snappy::SnappyScatteredWriter<snappy::SnappySinkAllocator>::SlowAppend(char const*, unsigned long) in libsnappy.a(snappy.cc.o)
"operator new(unsigned long)", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"___cxa_allocate_exception", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"___cxa_begin_catch", referenced from:
___clang_call_terminate in libsnappy.a(snappy.cc.o)
"___cxa_free_exception", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"___cxa_pure_virtual", referenced from:
vtable for snappy::Sink in libsnappy.a(snappy-sinksource.cc.o)
vtable for snappy::Source in libsnappy.a(snappy-sinksource.cc.o)
"___cxa_throw", referenced from:
void std::__1::vector<snappy::SnappySinkAllocator::Datablock, std::__1::allocator<snappy::SnappySinkAllocator::Datablock> >::__push_back_slow_path<snappy::SnappySinkAllocator::Datablock const>(snappy::SnappySinkAllocator::Datablock const&) in libsnappy.a(snappy.cc.o)
void std::__1::vector<char*, std::__1::allocator<char*> >::__push_back_slow_path<char* const>(char* const&) in libsnappy.a(snappy.cc.o)
"___gxx_personality_v0", referenced from:
snappy::GetUncompressedLength(snappy::Source*, unsigned int*) in libsnappy.a(snappy.cc.o)
snappy::Compress(snappy::Source*, snappy::Sink*) in libsnappy.a(snappy.cc.o)
snappy::RawUncompressToIOVec(char const*, unsigned long, iovec const*, unsigned long) in libsnappy.a(snappy.cc.o)
snappy::RawUncompressToIOVec(snappy::Source*, iovec const*, unsigned long) in libsnappy.a(snappy.cc.o)
snappy::RawUncompress(char const*, unsigned long, char*) in libsnappy.a(snappy.cc.o)
snappy::RawUncompress(snappy::Source*, char*) in libsnappy.a(snappy.cc.o)
snappy::Uncompress(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in libsnappy.a(snappy.cc.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
答案 0 :(得分:2)
似乎您的链接器找不到/usr/local/lib/libsnappy.a
。
尝试运行clang -Xlinker -v
,确保/usr/local/lib
中存在Library search paths
:
clang -Xlinker -v
@(#)PROGRAM:ld PROJECT:ld64-278.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/usr/lib
/usr/local/lib
通常,它会存在。然后尝试sudo update_dyld_shared_cache
。
谈论调试cmake
,您可以使用--debug-output
之类的标记:
cmake --debug-output --trace --debug-trycompile ..
<强>更新强>:
check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
实际上执行如下操作,它会尝试链接snappy
并查找函数是否存在:
cc -DCHECK_FUNCTION_EXISTS=snappy_compress -Wl,-search_paths_first -Wl,-headerpad_max_install_names -o check_snappy_exist CheckFunctionExists.c -lsnappy
您可以找到CheckFunctionExists.c
{{1}}的来源
我认为这将简化问题。
答案 1 :(得分:1)