erlang-czmq icon indicating copy to clipboard operation
erlang-czmq copied to clipboard

Compilation failed on macOS 10.12.4 (Sierra)

Open mezzomondo opened this issue 7 years ago • 3 comments

Hi,

I've got this error when compiling on OSX Sierra:

/tmp/erlang-czmq$ make
 APP    czmq.app.src
cd c_src; make
./build_czmq.sh
gcc -Wall -g2 -I/usr/local/Cellar/erlang/19.3/lib/erlang/lib/erl_interface-3.9.3/include -I/tmp/erlang-czmq/c_src/.libs/libsodium/include -I/tmp/erlang-czmq/c_src/.libs/libzmq/include -I/tmp/erlang-czmq/c_src/.libs/czmq/include -c czmq_benchmark.c -o czmq_benchmark.o
In file included from czmq_benchmark.c:41:
In file included from /tmp/erlang-czmq/c_src/.libs/czmq/include/czmq.h:19:
In file included from /tmp/erlang-czmq/c_src/.libs/czmq/include/czmq_prelude.h:210:
/usr/include/time.h:177:5: error: conflicting types for 'clock_gettime'
int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
    ^
czmq_benchmark.c:26:5: note: previous definition is here
int clock_gettime(int clk_id, struct timespec *t){
    ^
1 error generated.
make[1]: *** [czmq_benchmark.o] Error 1
make: *** [app] Error 2

I tried some hacky solution but I think I'm stuck.

mezzomondo avatar Apr 27 '17 12:04 mezzomondo

hey @mezzomondo this is the patch we run to fix this. you basically have to delete the function in czmq_benchmark.c

--- a/deps/czmq/c_src/czmq_benchmark.c	2017-01-19 12:02:44.000000000 -0800
+++ b/deps/czmq/c_src/czmq_benchmark.c	2017-01-19 12:07:27.000000000 -0800
@@ -23,17 +23,6 @@
 #include <mach/mach_time.h>
 #define CLOCK_REALTIME 0
 #define CLOCK_MONOTONIC 0
-int clock_gettime(int clk_id, struct timespec *t){
-    mach_timebase_info_data_t timebase;
-    mach_timebase_info(&timebase);
-    uint64_t time;
-    time = mach_absolute_time();
-    double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
-    double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
-    t->tv_sec = seconds;
-    t->tv_nsec = nseconds;
-    return 0;
-}
 #else
 #include <time.h>
 #endif

gregerg avatar Dec 06 '18 19:12 gregerg

If this is generally applicable, could you submit it as a PR? I'll merge it!

gar1t avatar Dec 06 '18 22:12 gar1t

Unfortunately, I'm not sure whether it's generally applicable or not. It's possible it is only a problem on the OS X

gregerg avatar Dec 12 '18 19:12 gregerg