1

我目前正在使用 xcode 8 开发一个 c++ 项目,并且不断收到此错误:

Undefined symbols for architecture x86_64:
"liblas::Reader::Reader(std::__1::basic_istream<char, std::__1::char_traits<char> >&)", referenced from:
  _main in main.o
"liblas::Reader::~Reader()", referenced from:
  _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经编译了 boost、liblas 等。我也将它包含在我的 cmakelists.txt 中,并在“框架搜索路径”和“标题搜索路径”中列出了它包含的文件夹。我的编译器是 Apple LLVM 8.0 的 xcode 8 默认值。我的部署目标是 10.11。有效的架构是“x86_64”和“i386”。

这是尝试使用 libLAS 的代码(file.las 包含我的 las 文件的硬编码路径)。此代码是直接从 libLAS c++ 教程中提取

std::ifstream ifs;
ifs.open("file.las", std::ios::in | std::ios::binary);
liblas::ReaderFactory f;
liblas::Reader reader = f.CreateWithStream(ifs);

如果我注释掉该行liblas::Reader reader = f.CreateWithStream(ifs);,代码编译得很好,并产生一个有效的可执行文件。使用此行,它会引发错误。但是,我需要能够使用该项目读取 LAS 文件,因此我需要尝试让 Reader 工作。

所以我的问题是:

  1. 有没有更好的方法来调试这个?

  2. 这是我遗漏的明显错误吗?

  3. 这是图书馆的问题吗?(libLAS)

  4. 我该怎么做才能让它工作?

提前感谢任何人!

4

0 回答 0