本文共 2708 字,大约阅读时间需要 9 分钟。
最近需要用到三角网格生成的一些东西,所以就把TRIANGLE这个库编译了一下,发现编译过程还是稍微有些纠结,于是就想到写下来,希望以后有些童鞋看到少走一些弯路。
首先非常感谢eryar的帮助,非常感谢!
在编译之前还是先看一下eryar的博文:
我是在visual studio 2010 windows环境下面编译的。
刚开始磕磕绊绊的也编译完了,但是在c++下面是不能使用的,所以求助eryar才最后成功:
直接上代码吧,triangle头文件更改如下:
#ifndef _TRIANGLE_HEADER_#define _TRIANGLE_HEADER_
#ifdef _cplusplusextern "C"{#endif///更改这里,博客加粗改颜色之后成代码了,不知为什么#define REAL double#define ANSI_DECLARATORS#define VOID int#include "triangle.h"struct triangulateio { REAL *pointlist; /* In / out */ REAL *pointattributelist; /* In / out */ int *pointmarkerlist; /* In / out */ int numberofpoints; /* In / out */ int numberofpointattributes; /* In / out */ int *trianglelist; /* In / out */ REAL *triangleattributelist; /* In / out */ REAL *trianglearealist; /* In only */ int *neighborlist; /* Out only */ int numberoftriangles; /* In / out */ int numberofcorners; /* In / out */ int numberoftriangleattributes; /* In / out */ int *segmentlist; /* In / out */ int *segmentmarkerlist; /* In / out */ int numberofsegments; /* In / out */ REAL *holelist; /* In / pointer to array copied out */ int numberofholes; /* In / copied out */ REAL *regionlist; /* In / pointer to array copied out */ int numberofregions; /* In / copied out */ int *edgelist; /* Out only */ int *edgemarkerlist; /* Not used with Voronoi diagram; out only */ REAL *normlist; /* Used only with Voronoi diagram; out only */ int numberofedges; /* Out only */};#ifdef ANSI_DECLARATORSvoid triangulate(char *, struct triangulateio *, struct triangulateio *,struct triangulateio *);void trifree(VOID *memptr);#else /* not ANSI_DECLARATORS */void triangulate();void trifree();#endif /* not ANSI_DECLARATORS */#ifdef _cplusplus}#endif///更改这里,博客加粗改颜色之后成代码了,不知为什么
#endif
同时在triangle.c里面修改:
将:
/* #define NO_TIMER */
/* #define TRILIBRARY*/
改为:
#define NO_TIMER
#define TRILIBRARY
也就是将这两个宏定义打开就OK了。
成功生成lib库
转载地址:http://foeji.baihongyu.com/