我正在尝试将一些来自CGAL的示例代码作为Qt项目在Qt Creator中运行。我预计需要修改.pro
文件。应如何修改以使用CGAL库?
我不太熟悉CGAL,但是一般而言,您需要将以下内容添加到您的.pro
文件中:
INCLUDEPATH += /path/to/cgal/headers
LIBS += -Lpath/to/cgal/libraries -lcgal_dll_name
如果CGAL需要,您可能还需要添加一些DEFINES
,例如:
DEFINES += SOME_MACRO_THAT_CGAL_REQUIRES
虽然这是一个旧问题,但为了提供更完整的答案,我必须在.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