c++ - 使用qt creator错误运行cgal示例

标签 c++ qt-creator fedora computational-geometry cgal

我是使用 CGAL 库的初学者,我正在 Fedora OS 开发 qt creator, 我构建并配置了 CGAL 包,然后创建了控制台应用程序并尝试了这个示例(与 CGAL 包一起安装):

// Author(s) : Camille Wormser, Pierre Alliez

#include <iostream>
#include <list>

#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>

typedef CGAL::Simple_cartesian<double> K;

typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Line_3 Line;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;

typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;

int main()
{
Point a(1.0, 0.0, 0.0);
Point b(0.0, 1.0, 0.0);
Point c(0.0, 0.0, 1.0);
Point d(0.0, 0.0, 0.0);

std::list<Triangle> triangles;
triangles.push_back(Triangle(a,b,c));
triangles.push_back(Triangle(a,b,d));
triangles.push_back(Triangle(a,d,c));

// constructs AABB tree
Tree tree(triangles.begin(),triangles.end());

// counts #intersections
Ray ray_query(a,b);
std::cout << tree.number_of_intersected_primitives(ray_query)
    << " intersections(s) with ray query" << std::endl;

// compute closest point and squared distance
Point point_query(2.0, 2.0, 2.0);
Point closest_point = tree.closest_point(point_query);
std::cerr << "closest point is: " << closest_point << std::endl;
FT sqd = tree.squared_distance(point_query);
std::cout << "squared distance: " << sqd << std::endl;

return EXIT_SUCCESS;
}

然后我将头文件添加到项目中: “Simple_cartesian.h” - “AABB_tree.h” - “AABB_traits.h” - “AABB_triangle_primitive.h”

但是在运行项目时我遇到了这些错误: :-1: 错误: main.o: 未定义对符号 '_ZN5boost6system15system_categoryEv' 的引用

:-1: error: note: '_ZN5boost6system15system_categoryEv' 在 DSO/lib64/libboost_system.so.1.54.0 中定义所以尝试将它添加到链接器命令行

/lib64/libboost_system.so.1.54.0:-1: 错误:无法读取符号:无效操作

:-1: error: collect2: error: ld 返回 1 退出状态

有什么帮助吗?

最佳答案

尝试将此行添加到您的 .pro 文件中:

LIBS += -lboost_system

当然,假设你已经下载并安装了boost.system图书馆。

关于c++ - 使用qt creator错误运行cgal示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35384551/

相关文章:

c++ - 计算单个派生类的实例

c++ - 基类集合泛型类型的通信

c++ - 为 boost python 编译的 .so 找不到模块

c++ - 使用 INSTALLS 变量安装 Qmake 的依赖项

c++ - 如何在 mac 版 qtcreator 中构建 .app

sh - 安装 Sublime Text 3 后的错误信息

c++ - unix域流套接字发送更多数据,那么它应该是

user-interface - Qt:关于动态 UI 的建议

c - 从不同文件传递时的指针损坏 Fedora 17

linux - PiDora PAM 允许 root 登录,但有时会拒绝