paullouisageneau / libjuice

JUICE is a UDP Interactive Connectivity Establishment library
Mozilla Public License 2.0
426 stars 80 forks source link

Install error: implicit declaration of function 'clock_gettime' is invalid in C99 #133

Closed OADesigns closed 2 years ago

OADesigns commented 2 years ago

I don't really know any C but am trying to install node-datachannel, and it uses libdatachannel and this, libjuice, as a dependency. This is on an older macOS, 10.10 I'm using as a test server. I'm using npm run build and the error stops the build and the exact error is:

[ 2%] Building C object _deps/libdatachannel-build/deps/libjuice/CMakeFiles/juice-static.dir/src/random.c.o /Users/testserver/Desktop/node-datachannel/build/_deps/libdatachannel-src/deps/libjuice/src/random.c:75:6: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration] if (clock_gettime(CLOCK_REALTIME, &ts) == 0) ^ /Users/testserver/Desktop/node-datachannel/build/_deps/libdatachannel-src/deps/libjuice/src/random.c:75:20: error: use of undeclared identifier 'CLOCK_REALTIME' if (clock_gettime(CLOCK_REALTIME, &ts) == 0) ^ 1 warning and 1 error generated. make[2]: [_deps/libdatachannel-build/deps/libjuice/CMakeFiles/juice-static.dir/src/random.c.o] Error 1 make[1]: [_deps/libdatachannel-build/deps/libjuice/CMakeFiles/juice-static.dir/all] Error 2 make: *** [all] Error 2 ERR! OMG Process terminated: 2

Am I doing something wrong? Any help or a workaround would be a life saver right now as I have no idea what to do.

paullouisageneau commented 2 years ago

The issue comes from macOS 10.10 which lacks the actual function, you need at least macOS 10.12. MacOS 10.10 is very old (it hasn't received security updates for a couple years now), is there a reason to use it?

paullouisageneau commented 2 years ago

I added a quick workaround: https://github.com/paullouisageneau/libjuice/pull/135

paullouisageneau commented 2 years ago

The fix is released in libjuice v0.9.3, to check it works with node-datachannel you'll need to change GIT_TAG to v0.15 or master here: https://github.com/murat-dogan/node-datachannel/blob/b6ce3bc90903be3160c4188bd094df8bfffe2e0e/CMakeLists.txt#L30

OADesigns commented 2 years ago

Yes I was using 10.10 because it runs on an older machine that starts to slow down whenever I update it. I appreciate you taking the time to create the workaround and will give it a try and let you know.If I still have issues I will probably have to find something that will install linux as I imagine it would give less headaches. Thank you again.