erlang-czmq
erlang-czmq copied to clipboard
Compilation failed on macOS 10.12.4 (Sierra)
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.
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
If this is generally applicable, could you submit it as a PR? I'll merge it!
Unfortunately, I'm not sure whether it's generally applicable or not. It's possible it is only a problem on the OS X