starseerdrgn: a white dragon with azure crystal horns and snout scales (Default)
2022-12-23 09:05 pm
Entry tags:

Compiling snownews 1.9 on Mac OS X Snow Leopard

So, I tried to compile snownews on Snow Leopard, because Newsboat doesn't compile due to rust, and I didn't want to go as far back as newsbeauter. However, I kept getting errors. It couldn't handle CLOCK_REALTIME from the time.h header, and it couldn't find the libintl headers from gettext. This is what I had to do:

1) I c/p'd this bit of code that I haven't been able to find again in search engines, but it fixed the CLOCK_REALTIME error:



#if defined(__MACH__) && !defined(CLOCK_REALTIME)
#include sys/time.h
#define CLOCK_REALTIME 0
// clock_gettime is not implemented on older versions of OS X (< 10.12).
// If implemented, CLOCK_REALTIME will have already been defined.
int clock_gettime(int /*clk_id*/, struct timespec* t) {
struct timeval now;
int rv = gettimeofday(&now, NULL);
if (rv) return rv;
t->tv_sec = now.tv_sec;
t->tv_nsec = now.tv_usec * 1000;
return 0;
}
#endif


2) I had to point the linker directly to the library name, as the library was in the right directory from my MacPorts install of gettext, but not seen. I edited the Config.mk file with the following, adding -lintl.8 just after the library folders:


ldflags += -L/opt/local/lib -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -lintl.8 -Wl,-search_paths_first ${LDFLAGS}


Once I made those changes, it compiled perfectly fine.