-1

I've got an error when I try to compile some code using CGAL in Qt Creator.

Here's my .pro file :

QT       += core

QT       -= gui

TARGET = TestCCGALAppliConsole
CONFIG   += console
CONFIG   -= app_bundle
CONFIG   -= x86_64
CONFIG   += i386

TEMPLATE = app

INCLUDEPATH += /opt/local/include
LIBS        += -L/opt/local/include

SOURCES += main.cpp



win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/release/ -lCGAL
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/debug/ -lCGAL
else:unix: LIBS += -L$$PWD/../../../opt/local/lib/ -lCGAL

INCLUDEPATH += $$PWD/../../../opt/local/include
DEPENDPATH += $$PWD/../../../opt/local/include


win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/release/ -lCGAL_ImageIO
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/debug/ -lCGAL_ImageIO
else:unix: LIBS += -L$$PWD/../../../opt/local/lib/ -lCGAL_ImageIO

INCLUDEPATH += $$PWD/../../../opt/local/include
DEPENDPATH += $$PWD/../../../opt/local/include

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/release/ -lCGAL_Core
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../opt/local/lib/debug/ -lCGAL_Core
else:unix: LIBS += -L$$PWD/../../../opt/local/lib/ -lCGAL_Core

INCLUDEPATH += $$PWD/../../../opt/local/include
DEPENDPATH += $$PWD/../../../opt/local/include

When I have this code (it's just an example), it works :

#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel2;
typedef Kernel2::Point_2 Point_2_2;

int main()
{
   // Point_2_2  p1(0, 0.3), q1(1, 0.6), r1(2, 0.9);
  {
    Point_2 p(0, 0.3), q(1, 0.6), r(2, 0.9);
    std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
  }
  {
    Point_2 p(0, 1.0/3.0), q(1, 2.0/3.0), r(2, 1);
    std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
  }
  {
    Point_2 p(0,0), q(1, 1), r(2, 2);
    std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
  }
  return 0;
}

But when I uncomment the first line in the main : Point_2_2 p1(0, 0.3), q1(1, 0.6), r1(2, 0.9);

It doesn't work and I have this error :

:-1: erreur : symbol(s) not found for architecture x86_64

Someone to help me ?

Thanks !

  • Show what command line actually gets executed, and the full error message. You are probably missing `-lmpfr -lgmp`. CMake would handle that for you if you used it. – Marc Glisse Apr 14 '15 at 12:00
  • I'm compiling directly in Qt Creator and that's the full error message. I've added `-lmpfr -lgmp` but it doesn't solve the problem. – Raphael Silveira Costa Apr 14 '15 at 12:48
  • The error you report is too short. Please try to find out which symbols are not found. It should be something in the complete compilation log. – lrineau Apr 14 '15 at 13:43
  • I've finally solved this problem adding `-lmpfr -lgm` , it works for mostly everything, BUT, when I use ``, I've got the same error and only when I use this header... – Raphael Silveira Costa Apr 15 '15 at 07:31
  • Think I found the problem [here](http://stackoverflow.com/questions/19689245/cgal-how-can-i-successfully-compile-and-link-cgal-examples-on-mac-os-x-10-9-ma) – Raphael Silveira Costa Apr 15 '15 at 07:43

1 Answers1

2

Here's the solution to the problem :

.pro file :

QT       += core

QT       -= gui

TARGET = TestCCGALAppliConsole
CONFIG   += console
CONFIG   -= app_bundle
CONFIG += c++11

TEMPLATE = app

INCLUDEPATH += /usr/local/include
DEPENDPATH  += /usr/local/include
LIBS        += -L/usr/local/include

macx: LIBS += -L/usr/local/lib/ -lgmp
macx: LIBS += -L/usr/local/lib/ -lmpfr
macx: LIBS += -L/usr/local/lib/ -lCGAL

SOURCES += main.cpp

main.cpp :

#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel2;
typedef Kernel2::Point_2 Point_2_2;

int main()
{
   Point_2_2  p1(0, 0.3), q1(1, 0.6), r1(2, 0.9);
   {
   Point_2 p(0, 0.3), q(1, 0.6), r(2, 0.9);
   std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
   }
   {
   Point_2 p(0, 1.0/3.0), q(1, 2.0/3.0), r(2, 1);
   std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
   }
   {
   Point_2 p(0,0), q(1, 1), r(2, 2);
   std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not collinear\n");
   }
   return 0;
}

Compiled with Clang (x86 64bit) and with Qt 5.4.1 clang 64bit version.