简体   繁体   English

在Shewchuk的Triangle程序上编译OSX上的C浮点运算

[英]Compiling C floating point arithmetic on OSX for Shewchuk's Triangle program

This question suggests that the best way to triangulate a polygon with holes is to use Shewchuk's Triangle library , but I'm having trouble getting it to compile on my mac OSX. 这个问题表明,对带有孔的多边形进行三角测量的最好方法是使用Shewchuk的Triangle库 ,但是我无法在mac OSX上编译它。 It is a very popular program that has been around for a while, and therefore should be relatively easy to compile, I'm just inexperienced with C. 这是一个非常受欢迎的程序已经存在了一段时间,因此应该相对容易编译,我只是缺乏经验C.

This is the error I'm getting: 这是我得到的错误:

$ make
cc -O -DLINUX -I/usr/X11R6/include -L/usr/X11R6/lib -o ./triangle ./triangle.c -lm
Undefined symbols:
  "__FPU_SETCW", referenced from:
   _exactinit in ccrEJvxc.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [triangle] Error 1

I'm trying to comment out certain flags (ie #define LINUX , etc.) but I get a different set of errors for each combination. 我试图注释掉某些标志(即#define LINUX等),但我为每个组合得到了一组不同的错误。

Could someone walk me through step-by-step how to compile (and possibly call) this program on a mac? 有人可以一步一步地指导我如何在mac上编译(并可能调用)这个程序吗?

我设法通过从makefile中的CSWITCHES定义中删除-DLINUX标志来编译OS X,因为fpu_control.h似乎是特定于linux的。

I don't believe that's a standard function and in any case I believe the Mac .. whose use of the Intel architecture post-dates SSE .. never had a reason to support 387-style FPU ops. 我不相信这是一个标准的功能,无论如何我相信Mac ...使用英特尔架构发布日期SSE ..从来没有理由支持387风格的FPU操作。

So your code is Linux-specific. 所以你的代码是特定于Linux的。 You can either remove the linux specific code or implement do-nothing versions of its entry points. 您可以删除特定于linux的代码,也可以实现其入口点的无用版本。

I wouldn't do this myself, but you might get away with: 我不会自己这样做,但你可能会逃避:

$ cat > /usr/include/fpu_control.h

#define _FPU_SETCW(cw) // nothing
#define _FPU_GETCW(cw) // nothing

Don't worry about the null implementations. 不要担心null实现。 You don't need to tweak the FPU exception and rounding modes. 您无需调整FPU异常和舍入模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM