开发者

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. 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.

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开发者_如何学Go:
   _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 (i.e. #define LINUX, etc.) but I get a different set of errors for each combination.

Could someone walk me through step-by-step how to compile (and possibly call) this program on a mac?


I managed to compile on OS X by removing the -DLINUX flag from the definition of CSWITCHES in the makefile, as fpu_control.h seems to be linux specific.


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.

So your code is Linux-specific. You can either remove the linux specific code or implement do-nothing versions of its entry points.

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. You don't need to tweak the FPU exception and rounding modes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜