Hi,

I managed to build lib2geom on OS X. Since it was not an easy task I thought it might be useful to share the information with the community.

I planned to write a small tutorial and make it available soon. But first I'd like to request some advice regarding the following issues I faced during the build.

1. Avoid glib dependency
I wanted to link lib2geom against my application without having to link against glib too so I replaced the following line in src/2geom/svg-path-parser.cpp:
_push(g_ascii_strtod(buf.c_str(), NULL));
with
_push(strtod(buf.c_str(), NULL));

and removed the glib.h include.

2. Removing librt
Since librt does not exist in OS X (and is not required too) I removed the following line in src/2geom/toys/CMakeLists.txt
TARGET_LINK_LIBRARIES(lpetoy "-lrt")
TARGET_LINK_LIBRARIES(toy-2 "-lrt")

3. Call to pow is ambiguous
Call to the pow function is ambiguous so I forced the call with casting by replacing
pow( ..., ... )
with
pow( (double) ..., (double) …)

in the following files:
boolops-topo.cpp
intersect-data.cpp
levelsets-test.cpp 
pencil-2.cpp
pencil.cpp
sb-to-bez.cpp
sketch-fitter.cpp
sweeper-toy.cpp

4. clock_gettime does not exist on OS X
In src/2geom/toys/toy-framework-2.h I replaced the following code snippet:

#ifdef WIN32
    clock_gettime(clock, &ts);
    ns = ts.tv_sec * NS_PER_SECOND + ts.tv_nsec / NS_PER_NS;
#else
    ns = 0;
#endif

with

#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
    clock_serv_t cclock;
    mach_timespec_t mts;
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
    clock_get_time(cclock, &mts);
    mach_port_deallocate(mach_task_self(), cclock);
    ts.tv_sec = mts.tv_sec;
    ts.tv_nsec = mts.tv_nsec;
    ns = ts.tv_sec * NS_PER_SECOND + ts.tv_nsec / NS_PER_NS;
#elif WIN32
    clock_gettime(clock, &ts);
    ns = ts.tv_sec * NS_PER_SECOND + ts.tv_nsec / NS_PER_NS;
#else
    ns = 0;
#endif

and add the required includes at the beginning of the file.
#ifdef __MACH__
# include <mach/clock.h>
# include <mach/mach.h>
#endif

See http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x

5. Cannot compile pw-toy.cpp
I was not able to compile src/2geom/toys/pw-toy.cpp so I simply disable it in src/2geom/toys/CmakeLists.txt.

src/2geom/toys/pw-toy.cpp:48:30: error: variable length array of non-POD element type 'Piecewise<Geom::SBasis>'
Piecewise<SBasis> pws[curves];

6. Missing return value
Added “return 0;” at the end of the function “cmpy” in uncross.cpp.

src/2geom/toys/uncross.cpp:175:5: error: control may reach end of non-void function [-Werror,-Wreturn-type]

That's all! :)

Thanks in advance
Regards.