使用 Qt Creator 编译 CGAL 时出错

Error compiling CGAL with Qt Creator

当我尝试在 Qt Creator 中使用 CGAL 编译一些代码时出现错误。

这是我的 .pro 文件:

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

当我有这段代码(这只是一个例子)时,它有效 :

#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;
}

但是当我取消注释 main 中的第一行时:Point_2_2 p1(0, 0.3), q1(1, 0.6), r1(2, 0.9);

它不起作用,我有这个错误:

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

有人帮我吗?

谢谢!

问题的解决方法如下:

.pro 文件:

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;
}

使用 Clang(x86 64 位)和 Qt 5.4.1 clang 64 位版本编译。