c++ - Mac OS X 上的 CGAL 链接错误

标签 c++ macos cgal

我用 macports 安装了 cgal:

$ sudo port install cgal

然后使用 cmake 构建我的示例代码:

$ cgal_create_CMakeLists -s out
$ cmake .
$ make

cmake 成功返回:

-- Requested component: MPFR
-- Requested component: GMP
-- Boost version: 1.54.0
-- Configuring done
-- Generating done
-- Build files have been written to: [...]

但是当我尝试在我的 .cpp 文件中使用 Exact_predicates_exact_constructions_kernel_with_sqrt 内核时,make 在链接阶段失败并出现以下错误。 Exact_predicates_exact_constructions_kernel 工作正常。

Linking CXX executable out
Undefined symbols for architecture x86_64:
  "CORE::EscapePrec", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::core_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, bool)", referenced from:
      CORE::filteredFp::operator/(CORE::filteredFp const&) const in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::filteredFp::sqrt() const in hello-really-exact.cpp.o
  "CORE::defAbsPrec", referenced from:
      CORE::Real::Real(CORE::BigRat const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::BigFloatValue() const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::sqrt(CORE::extLong const&) const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::sqrt(CORE::extLong const&, CORE::BigFloat const&) const in hello-really-exact.cpp.o
  "CORE::defRelPrec", referenced from:
      CORE::Real::Real(CORE::BigRat const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::BigFloatValue() const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::sqrt(CORE::extLong const&) const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::sqrt(CORE::extLong const&, CORE::BigFloat const&) const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::add(CORE::BigFloatRep const&, CORE::BigFloatRep const&)", referenced from:
      CORE::Real CORE::_real_add::eval<CORE::BigFloat>(CORE::BigFloat const&, CORE::BigFloat const&) in hello-really-exact.cpp.o
  "CORE::BigFloatRep::div(CORE::BigInt const&, CORE::BigInt const&, CORE::extLong const&, CORE::extLong const&)", referenced from:
      CORE::BigFloat::approx(CORE::BigRat const&, CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::BigFloat::BigFloat(CORE::BigRat const&, CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
  "CORE::BigFloatRep::sub(CORE::BigFloatRep const&, CORE::BigFloatRep const&)", referenced from:
      CORE::Real CORE::_real_sub::eval<CORE::BigFloat>(CORE::BigFloat const&, CORE::BigFloat const&) in hello-really-exact.cpp.o
  "CORE::BigFloatRep::sqrt(CORE::BigFloatRep const&, CORE::extLong const&)", referenced from:
      CORE::BigFloat::sqrt(CORE::extLong const&) const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::sqrt(CORE::BigFloatRep const&, CORE::extLong const&, CORE::BigFloat const&)", referenced from:
      CORE::BigFloat::sqrt(CORE::extLong const&, CORE::BigFloat const&) const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::trunc(CORE::BigInt const&, CORE::extLong const&, CORE::extLong const&)", referenced from:
      CORE::Realbase_for<long>::approx(CORE::extLong const&, CORE::extLong const&) const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigInt>::approx(CORE::extLong const&, CORE::extLong const&) const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::approx(CORE::BigFloatRep const&, CORE::extLong const&, CORE::extLong const&)", referenced from:
      CORE::Realbase_for<CORE::BigFloat>::approx(CORE::extLong const&, CORE::extLong const&) const in hello-really-exact.cpp.o
  "CORE::InvalidFlag", referenced from:
      CORE::sqrt(CORE::Expr const&) in hello-really-exact.cpp.o
      CORE::operator/(CORE::Expr const&, CORE::Expr const&) in hello-really-exact.cpp.o
  "CORE::fpFilterFlag", referenced from:
      CORE::filteredFp::isOK() const in hello-really-exact.cpp.o
  "CORE::EscapePrecFlag", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::EscapePrecWarning", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::rationalReduceFlag", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::progressiveEvalFlag", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::defInitialProgressivePrec", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::Add::name", referenced from:
      CORE::AddSubRep<CORE::Add>::op() const in hello-really-exact.cpp.o
  "CORE::Sub::name", referenced from:
      CORE::AddSubRep<CORE::Sub>::op() const in hello-really-exact.cpp.o
  "CORE::clLg(long)", referenced from:
      CORE::Realbase_for<long>::length() const in hello-really-exact.cpp.o
      CORE::Realbase_for<long>::height() const in hello-really-exact.cpp.o
  "CORE::clLg(unsigned long)", referenced from:
      CORE::Realbase_for<long>::ULV_E(CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&) const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigFloat>::clLgErr() const in hello-really-exact.cpp.o
  "CORE::flrLg(long)", referenced from:
      CORE::Real::Real(long) in hello-really-exact.cpp.o
  "CORE::flrLg(unsigned long)", referenced from:
      CORE::_real_binary_op<CORE::_real_add>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigFloat>::flrLgErr() const in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_sub>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
  "CORE::ExprRep::degreeBound()", referenced from:
      CORE::sqrt(CORE::Expr const&) in hello-really-exact.cpp.o
      CORE::operator/(CORE::Expr const&, CORE::Expr const&) in hello-really-exact.cpp.o
      CORE::Expr::cmp(CORE::Expr const&) const in hello-really-exact.cpp.o
  "CORE::ExprRep::getAppValue(CORE::extLong const&, CORE::extLong const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
  "CORE::ExprRep::computeBound()", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::ExprRep::reduceToZero()", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::ExprRep::reduceToBigRat(CORE::BigRat const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::ExprRep::reduceTo(CORE::ExprRep const*)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::ExprRep::ExprRep()", referenced from:
      CORE::DivRep::DivRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
      CORE::MultRep::MultRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::AddSubRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
      CORE::Expr::operator-() const in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::AddSubRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
      CORE::Expr::Expr(int) in hello-really-exact.cpp.o
      CORE::Expr::Expr() in hello-really-exact.cpp.o
      ...
  "CORE::extLong::getNegInfty()", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_add>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
      CORE::Real::Real(long) in hello-really-exact.cpp.o
      CORE::Realbase_for<long>::flrLgErr() const in hello-really-exact.cpp.o
      CORE::Realbase_for<long>::clLgErr() const in hello-really-exact.cpp.o
      CORE::Real::Real(CORE::BigInt const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigInt>::flrLgErr() const in hello-really-exact.cpp.o
      ...
  "CORE::extLong::getPosInfty()", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_add>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_sub>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
  "CORE::extLong::operator-=(CORE::extLong const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigRat>::ULV_E(CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&, CORE::extLong&) const in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
  "CORE::extLong::operator*=(CORE::extLong const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
  "CORE::extLong::operator+=(CORE::extLong const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_add>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
      CORE::Real::Real(CORE::BigRat const&) in hello-really-exact.cpp.o
      CORE::Real::Real(CORE::BigFloat const&) in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigFloat>::flrLgErr() const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigFloat>::clLgErr() const in hello-really-exact.cpp.o
      ...
  "CORE::BinOpRep::initNodeInfo()", referenced from:
      vtable for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      vtable for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "CORE::BinOpRep::count()", referenced from:
      vtable for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      vtable for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "CORE::BinOpRep::clearFlag()", referenced from:
      vtable for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      vtable for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "CORE::io_write(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, __mpq_struct const*)", referenced from:
      CORE::Realbase_for<CORE::BigRat>::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in hello-really-exact.cpp.o
  "CORE::io_write(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, __mpz_struct const*)", referenced from:
      CORE::Realbase_for<CORE::BigInt>::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in hello-really-exact.cpp.o
  "CORE::AbortFlag", referenced from:
      CORE::sqrt(CORE::Expr const&) in hello-really-exact.cpp.o
      CORE::operator/(CORE::Expr const&, CORE::Expr const&) in hello-really-exact.cpp.o
  "CORE::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, CORE::extLong const&)", referenced from:
      CORE::AddSubRep<CORE::Add>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Add>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeExactFlags() in hello-really-exact.cpp.o
      CORE::AddSubRep<CORE::Sub>::computeApproxValue(CORE::extLong const&, CORE::extLong const&) in hello-really-exact.cpp.o
  "CORE::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, CORE::ExprRep&)", referenced from:
      _main in hello-really-exact.cpp.o
  "CORE::BigFloatRep::compareMExp(CORE::BigFloatRep const&) const", referenced from:
      CORE::BigFloat::longValue() const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::toLong() const", referenced from:
      CORE::BigFloat::longValue() const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::toBigInt() const", referenced from:
      CORE::Realbase_for<CORE::BigFloat>::BigIntValue() const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::toDouble() const", referenced from:
      CORE::Realbase_for<CORE::BigFloat>::doubleValue() const in hello-really-exact.cpp.o
  "CORE::BigFloatRep::toDecimal(unsigned int, bool) const", referenced from:
      CORE::Realbase_for<CORE::BigFloat>::toString(long, bool) const in hello-really-exact.cpp.o
      CORE::Realbase_for<CORE::BigFloat>::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in hello-really-exact.cpp.o
  "CORE::extLong::operator-() const", referenced from:
      CORE::_real_binary_op<CORE::_real_add>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
      CORE::_real_binary_op<CORE::_real_sub>::eval(CORE::RealRep const&, CORE::RealRep const&) in hello-really-exact.cpp.o
  "CORE::BinOpRep::debugList(int, int) const", referenced from:
      vtable for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      vtable for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "CORE::BinOpRep::debugTree(int, int, int) const", referenced from:
      vtable for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      vtable for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "typeinfo for CORE::BinOpRep", referenced from:
      typeinfo for CORE::AddSubRep<CORE::Add> in hello-really-exact.cpp.o
      typeinfo for CORE::AddSubRep<CORE::Sub> in hello-really-exact.cpp.o
  "vtable for CORE::UnaryOpRep", referenced from:
      CORE::UnaryOpRep::~UnaryOpRep() in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::ConstDoubleRep", referenced from:
      CORE::Expr::Expr(int) in hello-really-exact.cpp.o
      CORE::Expr::Expr() in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::DivRep", referenced from:
      CORE::DivRep::DivRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::NegRep", referenced from:
      CORE::Expr::operator-() const in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::MultRep", referenced from:
      CORE::MultRep::MultRep(CORE::ExprRep*, CORE::ExprRep*) in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::SqrtRep", referenced from:
      CORE::SqrtRep::SqrtRep(CORE::ExprRep*) in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for CORE::BinOpRep", referenced from:
      CORE::BinOpRep::~BinOpRep() in hello-really-exact.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [out] Error 1
make[1]: *** [CMakeFiles/out.dir/all] Error 2
make: *** [all] Error 2

我在 Mac OS X 10.9.0 上

最佳答案

installation documentation 中所述, cgal_create_CMakeLists 采用参数来指定它应该链接的 CGAL 和 BOOST 组件。在这种情况下,您需要 -c Core。对需要哪些组件的自动检测相当有限,因此您通常需要自己指定它们。

$ cgal_create_CMakeLists -c Core -s out
$ cmake .
$ make

另一种方法是在同一目录中创建一个名为 cgal_cmake_options 的文件,或者在您的主​​目录中创建一个名为 .cgal_cmake_options_rc 的文件,其中包含:

CGAL_COMPONENT Core

请注意,如果您使用其中的几种方法,脚本不会累积选项。

关于c++ - Mac OS X 上的 CGAL 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19619569/

相关文章:

c++ - STL::find_if 与用户搜索

Python - OS X 中的屏幕抓取和控制鼠标

ios - 如何通过命令行在 Xcode 中登录 Apple ID?

c++ - CGAL 中的 Fixed_precision_nt 数字类型发生了什么变化?

c++ - 如何确定顶点是否在 CGAL 中网格的边界上

c++ - 有什么理由 find_if、for_each、count 等不需要 std::?

c++ - 创建一个只有模板头文件的项目库文件

C++ 在元组中存储原始字符数组

java - 使用java从e​​clipse运行Mac OSX命令

c++ - 如何将由矩形(边界框)裁剪的 voronoi 图转换为一组多边形?