Compiler errors CGAL编译器错误:未定义对“CGAL::assertion”的引用失败(char-const*、char-const*、int、char-const*)&x27;

Compiler errors CGAL编译器错误:未定义对“CGAL::assertion”的引用失败(char-const*、char-const*、int、char-const*)&x27;,compiler-errors,linker,g++,cgal,Compiler Errors,Linker,G++,Cgal,我是CGAL的新手,在Ubuntu 16.04上使用CGAL 4.7-4。 我正在尝试编译并运行一个非常简单的.cpp。代码如下: #include <iostream> #include <CGAL/Cartesian.h> int main() { int p=2; std::cout << "hello " << p << std::endl; return 0; } 但我有一个错误: /tmp/cc9DA7Ml.o:在

我是CGAL的新手,在Ubuntu 16.04上使用CGAL 4.7-4。 我正在尝试编译并运行一个非常简单的.cpp。代码如下:

#include <iostream>
#include <CGAL/Cartesian.h>

int main()
{
 int p=2;
 std::cout << "hello " << p << std::endl;
 return 0;
}
但我有一个错误:

/tmp/cc9DA7Ml.o:在函数“CGAL::Interval\u nt::Test\u runtime\u rounding\u modes::Test\u runtime\u rounding\u modes()”中:

prova.cpp:(.text."ZN4CGAL11Interval"ntILb0EE27Test"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntILb0EE27Test"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntILb0EE27Test运行时"取整"模式c5ev

prova.cpp:(.text."ZN4CGAL11Interval"ntILb0EE27Test"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntILb0EE27Test"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntILb0EE27Test运行时"取整"模式c5ev

/tmp/cc9DA7Ml.o:在函数“CGAL::Interval\u nt::Test\u runtime\u rounding\u modes::Test\u runtime\u rounding\u modes()”中:

prova.cpp:(.text."ZN4CGAL11Interval"ntilb1ee27测试"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntilb1ee27测试"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntilb1ee27测试"运行时"取整"模式c5ev

prova.cpp:(.text."ZN4CGAL11Interval"ntilb1ee27测试"运行时"取整"模式c2ev["ZN4CGAL11Interval"ntilb1ee27测试"运行时"取整"模式c2ev

collect2:错误:ld返回了1个退出状态

即使我写了以下任何一行,我也会犯同样的错误:

g++ -lCGAL -lmpfr -lgmp prova.cpp

g++ -I/opt/local/include -L/opt/local/lib -lCGAL -lgmp prova.cpp

g++ -I/opt/local/include -L/opt/local/lib/ -lCGAL -lgmp prova.cpp

g++ -I/usr/include -L/usr/bin -lCGAL -lgmp prova.cpp

g++ -I/usr/bin -L/usr/lib -lCGAL -lgmp prova.cpp
如果我写

g++ -lCartesian.a -lCGAL -lgmp prova.cpp

我在终端上发现了这个错误

g++ -lCGAL -lgmp prova.cpp
/usr/bin/ld:找不到-lCartesian.a

collect2:错误:ld返回了1个退出状态

最后如果我写

g++ -I/usr/include/CGAL -L/usr/include/CGAL -lCGAL -lgmp prova.cpp
我得到了一个很长的错误列表,如下所示:

在/usr/include/CGAL/gmpxx_-compression_-traits.h:35:0中包含的文件中

/usr/include/mpfr.h:181:3:错误:“mp\u limb\u t”未命名类型 mp_limb_t*_mpfr_d

/usr/include/mpfr.h:279:1:错误:“\uu GMP\u DECLSPEC”未命名类型 __MPFR_DECLSPEC_gmp_const char*MPFR_get_version_MPFR_PROTO((无效))

[……]

在/usr/include/CGAL/mpz_class.h:29:0中包含的文件中

/usr/include/CGAL/gmpxx_强制_traits.h:43:3:错误:“::_gmp_expr”尚未声明

::::\U gmp\U expr,:::\U gmp\U expr>{

[……]

长长的清单是这样结束的:

在/usr/include/CGAL/double.h:30:0中包含的文件中

/usr/include/CGAL/number_utils.h:在“typename CGAL::Real_embedded_traits::Is_finite::result_type CGAL::Is_finite(const Real_embedded&)[带Real_embedded=double;typename CGAL::Real_embedded__traits::Is_finite::result_type=CGAL::Null_tag]”的实例化中:

/usr/include/CGAL/double.h:201:27:此处需要

/usr/include/CGAL/number_utils.h:263:75:错误:调用“(CGAL::INTERN_RET::Real_embeddedable_traits_base>::Is_finite{aka CGAL::Null_functor})(const double&)'

返回typename Real\u embeddeble\u traits::Is_finite()(x);
我在网上查阅了很多,我知道编译的链接部分有问题(核心部分没有问题),但我真的不知道该解决方案。你有什么想法吗?提前感谢你的帮助

g++ prova.cpp -lCGAL

作品……似乎只是一个问题。

< P>简单地,使用C++版本14。< /P> 如果使用Qt,则在<代码>中执行以下C++版本。PRO/<代码>文件< < /P>
CONFIG += c++14
             from /usr/include/CGAL/mpz_class.h:29,
             from /usr/include/CGAL/gmpxx.h:47,
             from /usr/include/CGAL/is_convertible.h:28,
             from /usr/include/CGAL/Rational_traits.h:31,
             from /usr/include/CGAL/number_type_basic.h:48,
             from /usr/include/CGAL/basic.h:44,
             from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
             from /usr/include/CGAL/Cartesian.h:28,
             from prova.cpp:2:
             from /usr/include/CGAL/gmpxx.h:47,
             from /usr/include/CGAL/is_convertible.h:28,
             from /usr/include/CGAL/Rational_traits.h:31,
             from /usr/include/CGAL/number_type_basic.h:48,
             from /usr/include/CGAL/basic.h:44,
             from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
             from /usr/include/CGAL/Cartesian.h:28,
             from prova.cpp:2:
             from /usr/include/CGAL/number_type_basic.h:60,
             from /usr/include/CGAL/basic.h:44,
             from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
             from /usr/include/CGAL/Cartesian.h:28,
             from prova.cpp:2:
return typename Real_embeddable_traits< Real_embeddable >::Is_finite()( x );
g++ prova.cpp -lCGAL
CONFIG += c++14