Linux下CGAL编译不通过

大一新生,做作业需要用到cgal库。Ubuntu16.04系统

装好了cgal库后(usr/local/include/里有CGAL文件夹),尝试将CGAL-5.0.2/examples里的程式进行编译

但是好像编译不通过,比如 examples/Triangulation_2/constrained.cpp 源码在直接执行g++ constrained.cpp -o out 时产生错误

/tmp/ccvF93Cq.o: In function `CGAL::Gmpq_rep::Gmpq_rep()':
main.cpp:(.text._ZN4CGAL8Gmpq_repC2Ev[_ZN4CGAL8Gmpq_repC5Ev]+0x14): undefined reference to `__gmpq_init'
/tmp/ccvF93Cq.o: In function `CGAL::Gmpq_rep::~Gmpq_rep()':
main.cpp:(.text._ZN4CGAL8Gmpq_repD2Ev[_ZN4CGAL8Gmpq_repD5Ev]+0x14): undefined reference to `__gmpq_clear'
/tmp/ccvF93Cq.o: In function `CGAL::Gmpq::Gmpq(double)':
main.cpp:(.text._ZN4CGAL4GmpqC2Ed[_ZN4CGAL4GmpqC5Ed]+0x6a): undefined reference to `__gmpq_set_d'
/tmp/ccvF93Cq.o: In function `CGAL::Gmpq::operator==(CGAL::Gmpq const&) const':
main.cpp:(.text._ZNK4CGAL4GmpqeqERKS0_[_ZNK4CGAL4GmpqeqERKS0_]+0x33): undefined reference to `__gmpq_equal'
/tmp/ccvF93Cq.o: In function `CGAL::Gmpq::operator<(CGAL::Gmpq const&) const':
main.cpp:(.text._ZNK4CGAL4GmpqltERKS0_[_ZNK4CGAL4GmpqltERKS0_]+0x33): undefined reference to `__gmpq_cmp'
/tmp/ccvF93Cq.o: In function `CGAL::Mpzf::Mpzf(CGAL::Mpzf const&)':
main.cpp:(.text._ZN4CGAL4MpzfC2ERKS0_[_ZN4CGAL4MpzfC5ERKS0_]+0x8d): undefined reference to `__gmpn_copyi'
/tmp/ccvF93Cq.o: In function `CGAL::Mpzf::aors(CGAL::Mpzf const&, CGAL::Mpzf const&, int)':
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0xe5): undefined reference to `__gmpn_copyi'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x189): undefined reference to `__gmpn_copyi'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x355): undefined reference to `__gmpn_copyi'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x3a6): undefined reference to `__gmpn_copyi'
/tmp/ccvF93Cq.o:main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x404): more undefined references to `__gmpn_copyi' follow
/tmp/ccvF93Cq.o: In function `CGAL::Mpzf::aors(CGAL::Mpzf const&, CGAL::Mpzf const&, int)':
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x5a3): undefined reference to `__gmpn_add'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x631): undefined reference to `__gmpn_add'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x950): undefined reference to `__gmpn_copyi'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0x9cc): undefined reference to `__gmpn_neg'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0xa1f): undefined reference to `__gmpn_sub_1'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0xacd): undefined reference to `__gmpn_neg'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0xb39): undefined reference to `__gmpn_sub'
main.cpp:(.text._ZN4CGAL4Mpzf4aorsERKS0_S2_i[_ZN4CGAL4Mpzf4aorsERKS0_S2_i]+0xb64): undefined reference to `__gmpn_sub_1'
/tmp/ccvF93Cq.o: In function `CGAL::operator*(CGAL::Mpzf const&, CGAL::Mpzf const&)':
main.cpp:(.text._ZN4CGALmlERKNS_4MpzfES2_[_ZN4CGALmlERKNS_4MpzfES2_]+0xfd): undefined reference to `__gmpn_mul'
main.cpp:(.text._ZN4CGALmlERKNS_4MpzfES2_[_ZN4CGALmlERKNS_4MpzfES2_]+0x150): undefined reference to `__gmpn_mul'
collect2: error: ld returned 1 exit status

以下是编译的源码:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <gmpxx.h>
#include <gmp.h>

#include <assert.h>
#include <iostream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef CGAL::Exact_predicates_tag                               Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, CGAL::Default, Itag> CDT;
typedef CDT::Point Point;
typedef CDT::Edge  Edge;

int main() {
  CDT cdt;
    return 0;
}

作业ddl马上到了,一直卡在cgal不会用上……还请大佬指点!

c++

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问