【发布时间】:2011-12-15 17:32:14
【问题描述】:
我正在尝试将CGAL 中的一些示例代码作为 Qt 项目运行,以在 Qt Creator 中运行。我希望我将不得不修改.pro 文件。应该如何修改才能使用 CGAL 库?
【问题讨论】:
标签: c++ qt qt-creator cgal
我正在尝试将CGAL 中的一些示例代码作为 Qt 项目运行,以在 Qt Creator 中运行。我希望我将不得不修改.pro 文件。应该如何修改才能使用 CGAL 库?
【问题讨论】:
标签: c++ qt qt-creator cgal
我并不特别熟悉 CGAL,但一般而言,您需要将以下内容添加到您的 .pro 文件中:
INCLUDEPATH += /path/to/cgal/headers
LIBS += -Lpath/to/cgal/libraries -lcgal_dll_name
如果 CGAL 需要,您可能还需要添加一些 DEFINES,即
DEFINES += SOME_MACRO_THAT_CGAL_REQUIRES
如果您专门寻求 CGAL 方面的帮助,请澄清您的问题,我将删除此答案。
【讨论】:
虽然这是一个老问题,只是为了得到更完整的答案,这是我在 .pro 文件中必须做的:
INCLUDEPATH += /usr/include/
LIBS += -L/usr/include/
LIBS += -lCGAL
LIBS += -lgmp
LIBS += -lmpfr // not really needed for me, but added since gmp had to be added too
QMAKE_CXXFLAGS += -frounding-math -O3
不添加如下内容,这会让您遇到奇怪的错误消息,如this link 中所述。
INCLUDEPATH += /usr/include/CGAL # do NOT add this!
LIBS += -L/usr/include/CGAL # do NOT add this!
【讨论】:
我正在使用 Qt 4.8.6、gcc 和 Fedora 24,这是我用于 Qt-CGAL 项目的 .pro:
#-------------------------------------------------
#
# Project created by QtCreator 2017-01-08T14:50:29
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = My CGAL_test
TEMPLATE = app
LIBS += -lgmp -lmpfr -lCGAL
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
【讨论】: