Search code examples
architectureqt-creatorx86-64symbolscgal

Error compiling CGAL with Qt Creator


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 !


Solution

  • 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.