HTTrack Website Copier
Free software offline browser - FORUM
Subject: Re: Impossible to compile: strndup unavailable on OS X
Author: Gabriele Falcioni
Date: 08/24/2013 16:34
 
I had the same issue on Mac OS X 10.6.8, with HTTrack 3.47.24.
No compiler errors but a run-time error when I attempt to run the
application:

dyld: lazy symbol binding failed: Symbol not found: _strndup
  Referenced from: /usr/local/lib/libhttrack.2.dylib
  Expected in: flat namespace

dyld: Symbol not found: _strndup
  Referenced from: /usr/local/lib/libhttrack.2.dylib
  Expected in: flat namespace

Trace/BPT trap

The issue depends on the fact that Mac OS X 10.6.8 does not contain a suitable
implementation of strndup().

The issue may be corrected in version 3.47.24, with a small edit to the file
src/htscharset.c. It suffice to move a static implementation of strndup()
outside the preprocessor conditional: #ifdef _WIN32.

This is a quick'n'dirty fix that allows a succesful compilation of HTTrack on
Mac OS X 10.6.8.

A better fix would be to change the file src/htscharset.c to enclose the
static definition of strndup() inside a double guard such as:

#if defined(_WIN32) || (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
&& (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1068))

static char *strndup(const char *s, size_t size) {
  char *dest = malloc(size + 1);

  if (dest != NULL) {
    memcpy(dest, s, size);
    dest[size] = '\0';
    return dest;
  }
  return NULL;
}

#endif

I hope that this helps.

Regards,

GF
 
Reply Create subthread


All articles

Subject Author Date
Impossible to compile: strndup unavailable on OS X

07/02/2012 19:37
Re: Impossible to compile: strndup unavailable on OS X

08/24/2013 16:34
Re: Impossible to compile: strndup unavailable on OS X

10/24/2013 16:17
Re: Impossible to compile: strndup unavailable on OS X

11/12/2013 18:11
Re: Impossible to compile: strndup unavailable on OS X

01/30/2014 05:31
Re: Impossible to compile: strndup unavailable on OS X

03/25/2014 00:26
Re: Impossible to compile: strndup unavailable on OS X

03/31/2014 19:04




8

Created with FORUM 2.0.11