c – Mac OS X上的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,macos,cgal 来源: https://codeday.me/bug/20190831/1775419.html