1

I am trying to compile the last development version of Yap Prolog in OSX (Mountain Lion). The first time I tried I saw this message:

##################################################################
# ERROR: Could not find library archive (-larchive).  Dropped
# library(archive). Library archive is available from
# http://code.google.com/p/libarchive/
#
# Most Unix/Linux distributions are shipped with binaries.  Make
# sure to have the development library installed.  E.g.
#
#   Debian/Ubuntu/Mint: aptitude install libarchive-dev
#   Fedora/...      yum install libarchive-devel
#   MacOS (Macports):   port install libarchive
##################################################################

So I installed libarchive using mac ports as suggested with sudo port install libarchive. The installation was successful.

However, after compiling again it keeps saying that libarchive is missing. I tried to find a libarchive file in my system and I found an alias /opt/local/lib/libarchive.dylib pointing to /opt/local/lib/libarchive.2.dylib. Just in case I set the environment variable DYLD_LIBRARY_PATH to /opt/local/lib but the problem is still there.

Does someone have a clue how I can solve this ?

Sergio
  • 133

1 Answers1

1

The -devel packages usually contain header files, pkgconfig data and similar - anything one would need to link an application against the library in question. I'm not sure how ports work, but check /opt/local (or /opt/local/include) for archive.h and archive_entry.h. Without these files you won't be able to compile the application. Since the path sounds rather non-standard (/opt/local/...), you will likely need to tell the buildsystem, that is should look for the libraries and headers in that particular directory.

The basic generic layout of files on unix-like systems these days is governed by the Filesystem Hierarchy Standard. The most important parts are as follows:

PREFIX
|-- bin
|-- etc
|-- include
|-- lib
|-- sbin
`-- share
  • bin and sbin hold binaries (the programs you run) - this is why these directories are usually mentioned in the $PATH shell variable. The s in sbin used to stand for static as in statically linked binary, which doesn't need any dynamic linking and can be basically run "as-is".

  • lib (and/or lib64 or even lib32) hold the shared (and possibly also static) libraries

  • include contains header files enabling linking your code against libraries (basically APIs definitions).

  • etc and share are for configuration and additional data files.

  • PREFIX is usually /usr, /usr/local, /opt or /opt/<something> but you can as well create such structure in your home directory for example.

How to tell the buildsystem where to look for binaries depends on what bs the code uses. Usually this very kind of information is placed in either the README or INSTALL file that accompany the source. For example for GNU autotools, it is usually in the form of --with-name=PREFIX or --with-name-lib=PREFIX/lib --with-name-include=PREFIX/include arguments passed to the configure script. If this isn't available, you might want to explicitly export variables used by compiler and linker:

$ export CFLAGS="-IPREFIX/include $CFLAGS"
$ export LDFLAGS="-LPREFIX/lib $LDFLAGS"

In your case this would be -I/opt/local/include and -L/opt/local/lib respectively.

peterph
  • 30,838
  • thanks for answering. I did not find those files in /opt/local/lib, but I found an archive.h and archive_entry.h in /opt/local/include, and they seem to be related to libarchive. I would like to try what you said, how can I tell the build system to look at those files ? – Sergio Dec 06 '12 at 10:39
  • @Sergio /opt/local/include is correct (lib was my typo). I've updated the answer with a brief explanation. – peterph Dec 06 '12 at 16:37