2016-11-15 8 views
2

Я новичок в CGAL, и я использую CGAL 4.7-4 на Ubuntu 16.04 , Я пытаюсь скомпилировать и запустить очень простой .cpp. Вот код:Ошибка компилятора CGAL: неопределенная ссылка на `CGAL :: assertion_fail (char const *, char const *, int, char const *) '

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

int main() 
{ 
int p=2; 
std::cout << "hello " << p << std::endl; 
return 0; 
} 

Я добавил строку

#include <CGAL/Cartesian.h> 

, потому что я хочу видеть, как собрать с большим количеством библиотек. Тогда я написал эту строку на терминале

g++ -lCGAL -lgmp prova.cpp 

, но я получил эту ошибку:

/tmp/cc9DA7Ml.o: In function 'CGAL::Interval_nt::Test_runtime_rounding_modes::Test_runtime_rounding_modes()':

prova.cpp:(.text._ZN4CGAL11Interval_ntILb0EE27Test_runtime_rounding_modesC2Ev[_ZN4CGAL11Interval_ntILb0EE27Test_runtime_rounding_modesC5Ev]+0xd2): undefined reference to 'CGAL::assertion_fail(char const*, char const*, int, char const*)'

prova.cpp:(.text._ZN4CGAL11Interval_ntILb0EE27Test_runtime_rounding_modesC2Ev[_ZN4CGAL11Interval_ntILb0EE27Test_runtime_rounding_modesC5Ev]+0x180): undefined reference to 'CGAL::assertion_fail(char const*, char const*, int, char const*)'

/tmp/cc9DA7Ml.o: In function 'CGAL::Interval_nt::Test_runtime_rounding_modes::Test_runtime_rounding_modes()':

prova.cpp:(.text._ZN4CGAL11Interval_ntILb1EE27Test_runtime_rounding_modesC2Ev[_ZN4CGAL11Interval_ntILb1EE27Test_runtime_rounding_modesC5Ev]+0xd2): undefined reference to 'CGAL::assertion_fail(char const*, char const*, int, char const*)'

prova.cpp:(.text._ZN4CGAL11Interval_ntILb1EE27Test_runtime_rounding_modesC2Ev[_ZN4CGAL11Interval_ntILb1EE27Test_runtime_rounding_modesC5Ev]+0x180): undefined reference to 'CGAL::assertion_fail(char const*, char const*, int, char const*)'

collect2: error: ld returned 1 exit status

я получил ту же ошибку, даже если я написал кто-нибудь из этих строк:

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++ -lCartesian -lCGAL -lgmp prova.cpp 

Я получил эту ошибку на терминале

/usr/bin/ld: cannot find -lCartesian.a

collect2: error: ld returned 1 exit status

И в конце концов, если я написал

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

Я получил очень длинный список ошибок, как это:

In file included from /usr/include/CGAL/gmpxx_coercion_traits.h:35:0,

   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: 

/usr/include/mpfr.h:181:3: error: ‘mp_limb_t’ does not name a type mp_limb_t *_mpfr_d;

/usr/include/mpfr.h:279:1: error: ‘__GMP_DECLSPEC’ does not name a type __MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));

[...]

In file included from /usr/include/CGAL/mpz_class.h:29:0,

   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: 

/usr/include/CGAL/gmpxx_coercion_traits.h:43:3: error: ‘::__gmp_expr’ has not been declared

::__gmp_expr< T , U>,::__gmp_expr< T , U> >{

[...]

И длинный список заканчивается так:

In file included from /usr/include/CGAL/double.h:30:0,

   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: 

/usr/include/CGAL/number_utils.h: In instantiation of ‘typename CGAL::Real_embeddable_traits::Is_finite::result_type CGAL::is_finite(const Real_embeddable&) [with Real_embeddable = double; typename CGAL::Real_embeddable_traits::Is_finite::result_type = CGAL::Null_tag]’:

/usr/include/CGAL/double.h:201:27: required from here

/usr/include/CGAL/number_utils.h:263:75: error: no match for call to ‘(CGAL::INTERN_RET::Real_embeddable_traits_base >::Is_finite {aka CGAL::Null_functor}) (const double&)’

return typename Real_embeddable_traits<Real_embeddable>::Is_finite()(x); 

Я много искал в Интернете, и я понял, что что-то не так с ссылкой на часть компиляции (без проблем с ядром), но я действительно не имею никакого представления о решении , Есть ли у вас какие-либо идеи? Заранее благодарим за помощь.

ответ

1
g++ prova.cpp -lCGAL 

works ... Кажется, это был вопрос только порядка.

 Смежные вопросы

  • Нет связанных вопросов^_^