Windows下编译Triangle

news/2025/1/19 3:31:30/文章来源:https://www.cnblogs.com/dizhilang/p/18337899

前言

将我几年前还是“小小小白”时(目前将自己定义为“小白”),编译Triangle库时的场景记录了下来,那时候算是才开始接触开源项目,很多东西都不懂,本着一颗不会不懂就瞎折腾的精神,一路走来,之前在cnblog自己的另一个账号也记录过,现在这个新注册的号,买了会员,手动搬了过来。仅以此祭奠下这几年逝去的时光。

下载源码

http://www.cs.cmu.edu/~quake/triangle.html

解压

说明

showme是基于LINUX下的X11开发的,在windows下无法正常运行使,所以实际上用到的,也就是如下两个文件

编译

环境

win10
vs2017

新建解决方案

添加现有项,并删除原来项

修改项目属性

初次编译,报错

修改头文件

#ifndef _TRIANGLE_HEADER_  
#define _TRIANGLE_HEADER_
#ifdef _cplusplus
extern "C" {
#endif#define REAL double  
#define ANSI_DECLARATORS  
#define VOID int
#include "triangle.h"//_____________________________________________________________
//原来代码
//_____________________________________________________________#ifdef _cplusplus
}
#endif//_cplusplus#endif//_TRIANGLE_HEADER_

再次编译

修改源文件

再次编译

添加预处理器

再次运行

修改源文件

再次编译

至此debug编译成功

编译release

修改release下的项目属性

复制拷贝lib和头文件

复制头文件至C:\Shared_Folders\VCPKG_201912_installed_x64\include\triangle,注意此时复制的是修改后的头文件

复制C:\Users\Administrator\Documents\Visual Studio 2017\Projects\libTriangle\x64\Debug\libTriangle.lib

C:\Shared_Folders\VCPKG_201912_installed_x64\debug\lib\libTriangled.lib
(注意重命名,加以区别release与debug)
复制C:\Users\Administrator\Documents\Visual Studio 2017\Projects\libTriangle\x64\Release\libTriangle.lib

C:\Shared_Folders\VCPKG_201912_installed_x64\lib\libTriangle.lib

在目标项目里调用编译好的静态库

运行调用测试代码

    struct triangulateio in, mid, out, vorout;/* Define input points. */in.numberofpoints = 4;in.numberofpointattributes = 1;in.pointlist = (REAL *)malloc(in.numberofpoints * 2 * sizeof(REAL));in.pointlist[0] = 0.0;in.pointlist[1] = 0.0;in.pointlist[2] = 1.0;in.pointlist[3] = 0.0;in.pointlist[4] = 1.0;in.pointlist[5] = 10.0;in.pointlist[6] = 0.0;in.pointlist[7] = 10.0;in.pointattributelist = (REAL *)malloc(in.numberofpoints *in.numberofpointattributes *sizeof(REAL));in.pointattributelist[0] = 0.0;in.pointattributelist[1] = 1.0;in.pointattributelist[2] = 11.0;in.pointattributelist[3] = 10.0;in.pointmarkerlist = (int *)malloc(in.numberofpoints * sizeof(int));in.pointmarkerlist[0] = 0;in.pointmarkerlist[1] = 2;in.pointmarkerlist[2] = 0;in.pointmarkerlist[3] = 0;in.numberofsegments = 0;in.numberofholes = 0;in.numberofregions = 1;in.regionlist = (REAL *)malloc(in.numberofregions * 4 * sizeof(REAL));in.regionlist[0] = 0.5;in.regionlist[1] = 5.0;in.regionlist[2] = 7.0;            /* Regional attribute (for whole mesh). */in.regionlist[3] = 0.1;          /* Area constraint that will not be used. */printf("Input point set:\n\n");//report(&in, 1, 0, 0, 0, 0, 0);/* Make necessary initializations so that Triangle can return a *//*   triangulation in `mid' and a voronoi diagram in `vorout'.  */mid.pointlist = (REAL *)NULL;            /* Not needed if -N switch used. *//* Not needed if -N switch used or number of point attributes is zero: */mid.pointattributelist = (REAL *)NULL;mid.pointmarkerlist = (int *)NULL; /* Not needed if -N or -B switch used. */mid.trianglelist = (int *)NULL;          /* Not needed if -E switch used. *//* Not needed if -E switch used or number of triangle attributes is zero: */mid.triangleattributelist = (REAL *)NULL;mid.neighborlist = (int *)NULL;         /* Needed only if -n switch used. *//* Needed only if segments are output (-p or -c) and -P not used: */mid.segmentlist = (int *)NULL;/* Needed only if segments are output (-p or -c) and -P and -B not used: */mid.segmentmarkerlist = (int *)NULL;mid.edgelist = (int *)NULL;             /* Needed only if -e switch used. */mid.edgemarkerlist = (int *)NULL;   /* Needed if -e used and -B not used. */vorout.pointlist = (REAL *)NULL;        /* Needed only if -v switch used. *//* Needed only if -v switch used and number of attributes is not zero: */vorout.pointattributelist = (REAL *)NULL;vorout.edgelist = (int *)NULL;          /* Needed only if -v switch used. */vorout.normlist = (REAL *)NULL;         /* Needed only if -v switch used. *//* Triangulate the points.  Switches are chosen to read and write a  *//*   PSLG (p), preserve the convex hull (c), number everything from  *//*   zero (z), assign a regional attribute to each element (A), and  *//*   produce an edge list (e), a Voronoi diagram (v), and a triangle *//*   neighbor list (n).                                              */triangulate("pczAevn", &in, &mid, &vorout);printf("Initial triangulation:\n\n");//report(&mid, 1, 1, 1, 1, 1, 0);printf("Initial Voronoi diagram:\n\n");//report(&vorout, 0, 0, 0, 0, 1, 1);/* Attach area constraints to the triangles in preparation for *//*   refining the triangulation.                               *//* Needed only if -r and -a switches used: */mid.trianglearealist = (REAL *)malloc(mid.numberoftriangles * sizeof(REAL));mid.trianglearealist[0] = 3.0;mid.trianglearealist[1] = 1.0;/* Make necessary initializations so that Triangle can return a *//*   triangulation in `out'.                                    */out.pointlist = (REAL *)NULL;            /* Not needed if -N switch used. *//* Not needed if -N switch used or number of attributes is zero: */out.pointattributelist = (REAL *)NULL;out.trianglelist = (int *)NULL;          /* Not needed if -E switch used. *//* Not needed if -E switch used or number of triangle attributes is zero: */out.triangleattributelist = (REAL *)NULL;/* Refine the triangulation according to the attached *//*   triangle area constraints.                       */triangulate("prazBP", &mid, &out, (struct triangulateio *) NULL);printf("Refined triangulation:\n\n");//report(&out, 0, 1, 0, 0, 0, 0);/* Free all allocated arrays, including those allocated by Triangle. */free(in.pointlist);free(in.pointattributelist);free(in.pointmarkerlist);free(in.regionlist);free(mid.pointlist);free(mid.pointattributelist);free(mid.pointmarkerlist);free(mid.trianglelist);free(mid.triangleattributelist);free(mid.trianglearealist);free(mid.neighborlist);free(mid.segmentlist);free(mid.segmentmarkerlist);free(mid.edgelist);free(mid.edgemarkerlist);free(vorout.pointlist);free(vorout.pointattributelist);free(vorout.edgelist);free(vorout.normlist);free(out.pointlist);free(out.pointattributelist);free(out.trianglelist);free(out.triangleattributelist);QMessageBox::information(NULL, "INFO", "Finish", QMessageBox::Ok, QMessageBox::Ok);//return 0;
运行目标程序测试

我之前一直以为是自己编的测试数据不符合条件,所以才报错。
后来发现用Triangle库本身所提供的代码测试,仍然报错。就怀疑是编译除了问题。
但是编译时成功。
无意间发现了一个博客上提到的一个问题

https://blog.csdn.net/u010750137/article/details/106028070

抱着试一试的态度,修改了下。最终问题得到了解决。
重新编译,生产静态库后再次替换。
开源开发很多都是坑啊~~~~~~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/776442.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

LINUX下编译Triangle

将我几年前还是小小白时,编译Triangle库时的场景记录了下来前言 将我几年前还是“小小小白”时(目前将自己定义为“小白”),编译Triangle库时的场景记录了下来,那时候算是才开始接触开源项目,很多东西都不懂,本着一颗不会不懂就瞎折腾的精神,一路走来,之前在cnblog自己…

读零信任网络:在不可信网络中构建安全系统06授权

授权1. 授权 1.1. 授权决策不容忽视,所有访问请求都必须被授权 1.2. 数据存储系统和其他各支撑子系统是授权的基石 1.2.1. 子系统提供访问控制的权威数据源和评估依据,直接影响授权决策 1.2.2. 谨慎区分各子系统的职责和能力,需要将其严格隔离 1.2.3. 尽量避免将它们合并到一…

bugbountyhunter scope BARKER:第五滴血 存储型 XSS Filter 绕过 报告

经过简单的payload调试,发现存在 Filter检查:https://github.com/masatokinugawa/filterbypass/wiki/Browsers-XSS-Filter-Bypass-Cheat-Sheet发现payload: <script%20src=//sec875.com/1.html%0A--%3E 有效访问 https://5cc259cfb319-sec875.a.barker-social.com/group/1…

postmam响应数据的提取和关联,用于登录接口后面其他功能依赖登录功能

前置条件:postman创建环境变量 1、提取数据进行保存 2、提取数据后,点击发送请求出来的数据3、引用 生命不断追求不止

bugbountyhunter scope BARKER:第四滴血 DOM型 XSS 报告

使用赏猎技战法 https://www.cnblogs.com/sec875/p/18335838寻找功能点,熟悉功能点,收集参数,观察正常(提供预期值(对的)或(不对的))与异常(提供非预期值),威胁建模 登录功能点:https://5cc259cfb319-sec875.a.barker-social.com/login 输入不正确的账号,触发错误检查…

夏天厨房里面出现小甲虫是什么虫子 All In One

夏天厨房里面出现小甲虫是什么虫子 All In One 小甲虫 烟草甲夏天厨房里面出现小甲虫是什么虫子 All In One小甲虫烟草甲 锯角毛窃蠹(学名:Lasioderma serricorne),又称烟甲虫、烟草甲,为毛窃蠹属下的一个物种。毛窃蠹属原为标本甲科(Anobiidae)的成员,今改属蛛甲科。是…

go 微服务

RPC:协议 grpc:google开发的rpc框架,支持多个语言(轻量级) go-mirco:go语言的微服务框架

Linux学习——3 常用目录含义

/dev: U盘等硬件插入到机器产生的文件 /lib: 类似windows的dll文件,Linux是 .so文件 /sbin: 可执行的二进制文件,比如ls是命令,二进制命令,cd,mv等 /var: 比如/var/log 系统运行时候产生的各种信息和日志 /etc: 比如 /etc/nginx.conf 运维等软件的配置文件