3

I am trying to compile a library using clang. The library makes calls to 'unlink', which is not defined by clang:

libmv/src/third_party/OpenExif/src/ExifImageFileWrite.cpp:162:17: error: use of undeclared identifier 'unlink'; did you mean 'inline'?
            unlink( mTmpImageFile.c_str() ) ;

My question is, what is the clang equivalent of unlink? As I see it, the path forward would be to #define unlink somewhere with an equivalent routine.

MM.
  • 4,224
  • 5
  • 37
  • 74

1 Answers1

9

There is no "Clang equivalent". Neither GCC nor Clang have ever been responsible for defining unlink, though they do probably distribute the POSIX headers which do (I don't recall specifically where POSIX headers come from).

Unfortunately, this appears to be a bug with the library you're using; the OpenExif developers failed to include the correct headers. Different C++ implementations may internally #include various headers for their own purposes, which has apparently masked this bug on your previous toolchain.

You can hack your copy and/or submit a patch to add:

#include <unistd.h>
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • 1
    I will fix this when I get a chance, but for anyone with the exact same problem (specifically with OpenExif), the #include for unistd.h is #ifdef'd for Linux only. The fix is to include __APPLE__ in the condition. – MM. Oct 06 '15 at 22:29
  • I think the more proper way might be to add `#define HAVE_UNISTD_H 1` into ExifComp.h? – Omegaman Mar 12 '19 at 23:35
  • Normally third party libraries can be configured for a specific platform, and part of this configuration step would be to `#define HAVE_UNISTD_H` to `0` or `1`. – Mark Ingram Mar 13 '19 at 10:50