我正在尝试运行一些“
Hello world
“在Eclipse Oxygen下使用CGAL库进行测试,但由于十几个未定义的引用错误,我失败了。
我按照建议的
apt-driven installation method
通过运行
sudo apt-get install libcgal-dev
sudo apt-get install libcgal-demo
但现在我完全不知道如何链接库,如何让Eclipse正确地包含和使用CGAL。
这是我正在尝试构建的程序:
#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <sstream>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
int main()
{
Point_2 p(0, 0.3), q, r(2, 0.9);
{
q = Point_2(1, 0.6);
std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not
collinear\n");
}
{
std::istringstream input("0 0.3 1 0.6 2 0.9");
input >> p >> q >> r;
std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not
collinear\n");
}
{
q = CGAL::midpoint(p,r);
std::cout << (CGAL::collinear(p,q,r) ? "collinear\n" : "not
collinear\n");
}
return 0;
}
这是我收到的错误的一个例子:
make all
Building target: exact
Invoking: Cross G++ Linker
g++ -L/usr/lib/x86_64-linux-gnu -L/usr/lib -o "exact" ./exact.o
./exact.o: In function `CGAL::Handle::Handle(CGAL::Handle const&)':
/usr/include/CGAL/Handle.h:55: undefined reference to
`CGAL::precondition_fail(char const*, char const*, int, char const*)'
makefile:44: recipe for target 'exact' failed
我试图将GCAL库位于Eclipse中的目录包含在交叉G++链接器和交叉GCC编译器下,但没有成功。
不幸的是,我对C++编程和Eclipse都是一个初学者!
谢谢你的帮助!