mardi 2 août 2016

CGAL is not working after installation

I installed CGAL on Ubuntu via terminal with sudo apt-get install libcgal-dev and sudo apt-get install libcgal-demo as recommended in CGAL's webpage. Then I tested "Hello World" example by copying example as below.

#include <iostream>
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Segment_2 Segment_2;
int main()
{
  Point_2 p(1,1), q(10,10);
  std::cout << "p = " << p << std::endl;
  std::cout << "q = " << q.x() << " " << q.y() << std::endl;
  std::cout << "sqdist(p,q) = " 
            << CGAL::squared_distance(p,q) << std::endl;

  Segment_2 s(p,q);
  Point_2 m(5, 9);

  std::cout << "m = " << m << std::endl;
  std::cout << "sqdist(Segment_2(p,q), m) = "
            << CGAL::squared_distance(s,m) << std::endl;
  std::cout << "p, q, and m ";
  switch (CGAL::orientation(p,q,m)){
  case CGAL::COLLINEAR: 
    std::cout << "are collinear\n";
    break;
  case CGAL::LEFT_TURN:
    std::cout << "make a left turn\n";
    break;
  case CGAL::RIGHT_TURN: 
    std::cout << "make a right turn\n";
    break;
  }
  std::cout << " midpoint(p,q) = " << CGAL::midpoint(p,q) << std::endl;
  return 0;
}

Compiling with g++ main.cpp resulted in several errors such as:

/tmp/ccu47rCm.o: In function `std::ostream& CGAL::insert<CGAL::Simple_cartesian<double> >(std::ostream&, CGAL::Point_2<CGAL::Simple_cartesian<double> > const&, CGAL::Cartesian_tag const&)':
main.cpp:(.text._ZN4CGAL6insertINS_16Simple_cartesianIdEEEERSoS3_RKNS_7Point_2IT_EERKNS_13Cartesian_tagE[_ZN4CGAL6insertINS_16Simple_cartesianIdEEEERSoS3_RKNS_7Point_2IT_EERKNS_13Cartesian_tagE]+0x19): undefined reference to `CGAL::IO::mode'
/tmp/ccu47rCm.o: In function `CGAL::Interval_nt<false>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()':
main.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*)'
main.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/ccu47rCm.o: In function `CGAL::Interval_nt<true>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()':
main.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*)'
main.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

Aucun commentaire:

Enregistrer un commentaire