使用 CGAL 编译一个简单的测试

2023-12-06

我刚刚在 mac 系统上用brew安装了CGAL。现在我很高兴通过一个简单且最小的示例来尝试它。我可以用g++编译它吗?

我想用以下命令编译这个示例文件:

gcc namefile.cpp -lCGAL -I/usr/local/include/CGAL

我遇到了很多错误...(我想太多了,无法将其粘贴到这里)

作为我正在使用的示例文件

File: examples/Arrangement_on_surface_2/sweep_line.cpp



#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <list>

typedef CGAL::Quotient<CGAL::MP_Float>                  NT;
typedef CGAL::Cartesian<NT>                             Kernel;
typedef Kernel::Point_2                                 Point_2;
typedef CGAL::Arr_segment_traits_2<Kernel>              Traits_2;
typedef Traits_2::Curve_2                               Segment_2;

int main()
{
  // Construct the input segments.
  Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)),
                          Segment_2 (Point_2 (1, 1), Point_2 (8, 8)),
                          Segment_2 (Point_2 (3, 1), Point_2 (3, 8)),
                          Segment_2 (Point_2 (8, 5), Point_2 (8, 8))};

  // Compute all intersection points.
  std::list<Point_2>     pts;

  CGAL::compute_intersection_points (segments, segments + 4,
                                     std::back_inserter (pts));

  // Print the result.
  std::cout << "Found " << pts.size() << " intersection points: " << std::endl; 
  std::copy (pts.begin(), pts.end(),
             std::ostream_iterator<Point_2>(std::cout, "\n"));

  // Compute the non-intersecting sub-segments induced by the input segments.
  std::list<Segment_2>   sub_segs;

  CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs));

  std::cout << "Found " << sub_segs.size()
            << " interior-disjoint sub-segments." << std::endl;

  CGAL_assertion (CGAL::do_curves_intersect (segments, segments + 4));

  return 0;
}

EDIT:

>>> g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

>>> g++ sweep_line.cpp
In file included from /usr/local/include/CGAL/Bbox_2.h:31,
                 from /usr/local/include/CGAL/basic_classes.h:31,
                 from /usr/local/include/CGAL/Cartesian/Cartesian_base.h:29,
                 from /usr/local/include/CGAL/Cartesian.h:28,
                 from sweep_line.cpp:4:
/usr/local/include/CGAL/array.h:81: error: expected nested-name-specifier before '...' token
/usr/local/include/CGAL/array.h:81: error: expected '>' before '...' token
/usr/local/include/CGAL/array.h:83: error: template argument 2 is invalid
/usr/local/include/CGAL/array.h:84: error: expected ',' or '...' before '&' token
/usr/local/include/CGAL/array.h: In function 'int CGAL::make_array(const T&, int)':
/usr/local/include/CGAL/array.h:86: error: template argument 2 is invalid
/usr/local/include/CGAL/array.h:86: error: invalid type in declaration before '=' token
/usr/local/include/CGAL/array.h:86: error: 'args' was not declared in this scope
/usr/local/include/CGAL/array.h:86: error: expected `}' before '...' token
/usr/local/include/CGAL/array.h:86: error: expected `}' before '...' token
/usr/local/include/CGAL/array.h:86: error: expected ',' or ';' before '...' token
/usr/local/include/CGAL/array.h: At global scope:
/usr/local/include/CGAL/array.h:87: error: expected unqualified-id before 'return'
/usr/local/include/CGAL/array.h:88: error: expected declaration before '}' token
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



>>>g++ sweep_line.cpp -lCGAL -I/usr/local/include/CGAL
In file included from /usr/local/include/CGAL/gmpxx_coercion_traits.h:35,
                 from /usr/local/include/CGAL/mpz_class.h:29,
                 from /usr/local/include/CGAL/gmpxx.h:47,
                 from /usr/local/include/CGAL/is_convertible.h:28,
                 from /usr/local/include/CGAL/Rational_traits.h:31,
                 from /usr/local/include/CGAL/number_type_basic.h:65,
                 from /usr/local/include/CGAL/basic.h:36,
                 from /usr/local/include/CGAL/Cartesian/Cartesian_base.h:28,
                 from /usr/local/include/CGAL/Cartesian.h:28,
                 from sweep_line.cpp:4:
/usr/local/include/mpfr.h:181: error: expected ';' before '*' token
/usr/local/include/mpfr.h:279: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:280: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:281: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:282: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:283: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:284: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:286: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:287: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:288: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:289: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:290: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:291: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:292: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:293: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:295: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:296: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:297: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:300: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:301: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:302: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:303: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:304: error: expected constructor, destructor, or type conversion before 'void'

你应该使用 -I /usr/local/包括 代替 -I/usr/local/include/CGAL

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 CGAL 编译一个简单的测试 的相关文章

  • 如何在MVVM中管理多个窗口

    我知道有几个与此类似的问题 但我还没有找到明确的答案 我正在尝试深入研究 MVVM 并尽可能保持纯粹 但不确定如何在坚持模式的同时启动 关闭窗口 我最初的想法是向 ViewModel 发送数据绑定命令 触发代码来启动一个新视图 然后通过 X
  • 是否可以强制 XMLWriter 将元素写入单引号中?

    这是我的代码 var ptFirstName tboxFirstName Text writer WriteAttributeString first ptFirstName 请注意 即使我使用 ptFirstName 也会以双引号结束 p
  • ASP.NET Core Serilog 未将属性推送到其自定义列

    我有这个设置appsettings json对于我的 Serilog 安装 Serilog MinimumLevel Information Enrich LogUserName Override Microsoft Critical Wr
  • 将数组向左或向右旋转一定数量的位置,复杂度为 o(n)

    我想编写一个程序 根据用户的输入 正 gt 负 include
  • UML类图:抽象方法和属性是这样写的吗?

    当我第一次为一个小型 C 项目创建 uml 类图时 我在属性方面遇到了一些麻烦 最后我只是将属性添加为变量 lt
  • 未解决的包含:“cocos2d.h” - Cocos2dx

    当我在 Eclipse 中导入 cocos2dx android 项目时 我的头文件上收到此警告 Unresolved inclusion cocos2d h 为什么是这样 它实际上困扰着我 该项目可以正确编译并运行 但我希望这种情况消失
  • 如何避免情绪低落?

    我有一个实现状态模式每个状态处理从事件队列获取的事件 根据State因此类有一个纯虚方法void handleEvent const Event 事件继承基础Event类 但每个事件都包含其可以是不同类型的数据 例如 int string
  • 实时服务器上的 woff 字体 MIME 类型错误

    我有一个 asp net MVC 4 网站 我在其中使用 woff 字体 在 VS IIS 上运行时一切正常 然而 当我将 pate 上传到 1and1 托管 实时服务器 时 我得到以下信息 网络错误 404 未找到 http www co
  • 指针问题(仅在发布版本中)

    不确定如何描述这一点 但我在这里 由于某种原因 当尝试创建我的游戏的发布版本进行测试时 它的敌人创建方面不起作用 Enemies e level1 3 e level1 0 Enemies sdlLib 500 2 3 128 250 32
  • 获取没有非标准端口的原始 url (C#)

    第一个问题 环境 MVC C AppHarbor Problem 我正在调用 openid 提供商 并根据域生成绝对回调 url 在我的本地机器上 如果我点击的话 效果很好http localhost 12345 login Request
  • C#:如何防止主窗体过早显示

    在我的 main 方法中 我像往常一样启动主窗体 Application EnableVisualStyles Application SetCompatibleTextRenderingDefault false Application
  • Web API - 访问 DbContext 类中的 HttpContext

    在我的 C Web API 应用程序中 我添加了CreatedDate and CreatedBy所有表中的列 现在 每当在任何表中添加新记录时 我想填充这些列 为此目的我已经覆盖SaveChanges and SaveChangesAsy
  • vector 超出范围后不清除内存

    我遇到了以下问题 我不确定我是否错了或者它是一个非常奇怪的错误 我填充了一个巨大的字符串数组 并希望在某个点将其清除 这是一个最小的例子 include
  • 在数据库中搜索时忽略空文本框

    此代码能够搜索数据并将其加载到DataGridView基于搜索表单文本框中提供的值 如果我将任何文本框留空 则不会有搜索结果 因为 SQL 查询是用 AND 组合的 如何在搜索 从 SQL 查询或 C 代码 时忽略空文本框 private
  • 从路径中获取文件夹名称

    我有一些路c server folderName1 another name something another folder 我如何从那里提取最后一个文件夹名称 我尝试了几件事 但没有成功 我只是不想寻找最后的 然后就去休息了 Thank
  • Qt表格小部件,删除行的按钮

    我有一个 QTableWidget 对于所有行 我将一列的 setCellWidget 设置为按钮 我想将此按钮连接到删除该行的函数 我尝试了这段代码 它不起作用 因为如果我只是单击按钮 我不会将当前行设置为按钮的行 ui gt table
  • clang 实例化后静态成员初始化

    这样的代码可以用 GCC 编译 但 clang 3 5 失败 include
  • 如何在 VBA 中声明接受 XlfOper (LPXLOPER) 类型参数的函数?

    我在之前的回答里发现了问题 https stackoverflow com q 19325258 159684一种无需注册即可调用 C xll 中定义的函数的方法 我之前使用 XLW 提供的注册基础结构 并且使用 XlfOper 类型在 V
  • 为什么 C# Math.Ceiling 向下舍入?

    我今天过得很艰难 但有些事情不太对劲 在我的 C 代码中 我有这样的内容 Math Ceiling decimal this TotalRecordCount this PageSize Where int TotalRecordCount
  • Validation.ErrorTemplate 的 Wpf 动态资源查找

    在我的 App xaml 中 我定义了一个资源Validation ErrorTemplate 这取决于动态BorderBrush资源 我打算定义独特的BorderBrush在我拥有的每个窗口以及窗口内的不同块内

随机推荐

  • SQL Server XACT_ABORT 排除

    我有一个更大的存储过程 它利用多个 TRY CATCH 块来捕获并记录各个错误 我还在过程的整个内容周围封装了一个事务 以便能够在沿途某个地方发生错误时回滚整个过程 以防止大量混乱的清理 XACT ABORT 已启用 否则它不会回滚整个事务
  • 将字符串分割成一定大小的块

    假设我有一个字符串 string str 1111222233334444 我怎样才能把这个字符串分成一定大小的块 例如 将其分解为 4 的大小将返回字符串 1111 2222 3333 4444 static IEnumerable
  • React-Table 的导入问题

    我正在使用react table库在react中创建一个表 几天前 我使用同一个库创建了一个表 没有遇到任何问题 但今天我收到以下错误 尝试导入错误 react table 不包含默认导出 导入为 ReactTable 进口声明 从 反应表
  • C# 中带有布尔条件的三元

    如果我要编写这段代码 它可以与正常的 if else 布局一起正常工作 if isOn i 10 else i 20 虽然我不确定如何使用三元运算符进行转换 isOn true i 1 i 0 错误 无法确定条件表达式的类型 因为 void
  • 如何覆盖默认的 Liferay 登录身份验证?

    我正在使用 Liferay 6 1 我想覆盖默认的 Liferay 登录身份验证并希望设置我的自定义身份验证 到目前为止 我所做的是 我创建了一个钩子插件 并在 Portal properties 文件中设置了以下属性 auth pipel
  • 将 MSBuild PublishProfile 与 Visual Studio 2012 结合使用时,MSDeploy 跳过规则

    我正在尝试使用 WebDeploy 通过自定义 MSDeploy 跳过规则和 Visual Studio 2012 中保存的发布配置文件来发布网站 我可以从命令行使用发布配置文件 但跳过删除文件夹的跳过规则不起作用 我有一个ErrorLog
  • 具有相同密钥的多个条目:24.0.0 rc4=24.0.0 rc4

    将 Android Studio 升级到 2 2 3 后 显示错误 IllegalArgumentException 具有相同密钥的多个条目 24 0 0 rc4 24 0 0 rc4 和 24 0 0 rc4 24 0 0 rc4 最近更
  • 从 VS Code 在终端中运行文件

    是否有任何 VS Code 快捷方式可以让您在 Windows 终端中运行文件 而无需将文件的路径直接写入终端 提前致谢 Try key ctrl shift t command workbench action terminal send
  • 内联汇编的“现实”用途有哪些? [复制]

    这个问题在这里已经有答案了 有什么是我们可以在汇编中做但在原始 C 中不能做的吗 或者有什么在组装中更容易做的事情吗 是否有任何现代代码实际上是使用内联汇编编写的 或者它只是作为遗留或教育功能实现 内联汇编 以及相关说明 调用纯粹用汇编语言
  • Eclipse ADT Bundle 在 Mint 16 Petra 上突然崩溃

    我最近在我的笔记本电脑 四核 8 GB 内存 上安装了 Linux Mint 16 Petra Cinnamon 64 位 我下载了适用于 Linux 64 位 的 ADT Bundle 当我开始使用 Eclipse 在 Android 中
  • 用于跟踪 Visual Studio 中项目的总工作时间的附加组件

    VS2010 是否有一个扩展可以跟踪项目上花费的总时间 因此 开发人员可以看到他为特定解决方案的开发贡献了多少时间 None
  • 在 Jinja2 中合并多个列表

    有没有办法在 Jinja2 的列表中组合多个列表 例如 如果我有 foo moo py jinga template example stack overflow 我期望得到 foo moo py jinga template exampl
  • 如何对包含异步的函数返回的值使用 List.sort?

    我有这个代码 widget items sort a b await getItemDistance a true await getItemDistance b false return itemADistance compareTo i
  • PySide 如何在 python 控制台中查看 QML 错误?

    我有以下代码 if name main os environ QT QUICK CONTROLS STYLE Material app QGuiApplication sys argv engine QQmlApplicationEngin
  • 带条件的正则表达式

    我有一个表 其中存储某些单词或单词组 我想选择以大写字母开头 不包含空格且仅包含字母的条目 我的 SQL 看起来像这样 select word from words where w id gt 100 AND word REGEXP A Z
  • 如何在 TensorFlow 的 MNIST 示例中获取预测的类标签?

    我是神经网络新手 并浏览了针对初学者的 MNIST 示例 我目前正在尝试在 Kaggle 的另一个没有测试标签的数据集上使用此示例 如果我在没有相应标签的测试数据集上运行模型 因此无法像 MNIST 示例中那样计算准确性 我希望能够看到预测
  • dojo dgrid 多个单元格编辑

    是否可以同时编辑 dgrid 的多个单元格 我知道我们可以通过双击 单击该单元格一次编辑一个单元格并更新它 并在onBlur该单元格的编辑数据将针对该单元格进行更新 但我的要求是 单击每行的编辑链接 编辑按钮 这将显示该行所有可编辑单元格的
  • Android Camera API - 奇怪的缩放效果[关闭]

    Closed 这个问题不符合堆栈溢出指南 目前不接受答案 这个问题似乎偏离主题 因为它缺乏足够的信息来诊断问题 更详细地描述您的问题或包括一个最小的例子在问题本身 有关您编写的代码的问题必须描述具体问题 and 包含有效代码重现它 在问题本
  • XPath :绑定到集合的最后一项

    Can I Bind TextBox Text到最后一项ObservableCollection
  • 使用 CGAL 编译一个简单的测试

    我刚刚在 mac 系统上用brew安装了CGAL 现在我很高兴通过一个简单且最小的示例来尝试它 我可以用g 编译它吗 我想用以下命令编译这个示例文件 gcc namefile cpp lCGAL I usr local include CG