I am using Libtool and the other GNU Autotools (Autoconf, Automake, etc.) to build a shared library. My library has a dependency on another library (hwloc). I allow the user to specify a custom path for hwloc at configuration (the following is in configure.ac
):
# Check for hwloc
AC_ARG_WITH([hwloc], [AS_HELP_STRING([--with-hwloc[[=DIR]]], [Location of the hwloc library])])
AS_IF([test "x$with_hwloc" != x],
[CPPFLAGS="-I$with_hwloc/include $CPPFLAGS"
LDFLAGS="-L$with_hwloc/lib $LDFLAGS"])
AC_CHECK_HEADERS([hwloc.h], [], [AC_MSG_ERROR([hwloc is a required library])])
AC_SEARCH_LIBS([hwloc_topology_init], [hwloc], [], [AC_MSG_ERROR([hwloc is a required library])])
After doing the build process (./configure --with-hwloc=...
; make
; make install
), my shared library file successfully links with hwloc (ldd libmylib.so
):
linux-vdso.so.1 => (0x00007ffff331c000)
librt.so.1 => /lib64/librt.so.1 (0x00007fa225c63000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa225a46000)
libhwloc.so.5 => /home/brooks8/bin/hwloc-1.8.1/lib/libhwloc.so.5 (0x00007fa225816000)
libm.so.6 => /lib64/libm.so.6 (0x00007fa225591000)
libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007fa22523f000)
libc.so.6 => /lib64/libc.so.6 (0x00007fa224eab000)
/lib64/ld-linux-x86-64.so.2 (0x0000003532000000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fa224ca6000)
libz.so.1 => /lib64/libz.so.1 (0x00007fa224a90000)
However, one of my header files includes hwloc. This causes problems when I try and test my library and hwloc is in a non-standard location:
mpicc test.c -I/home/brooks8/bin/mylib/include -L/home/brooks8/bin/mylib/lib -lmylib -o test/test -std=c99 -O3 -g3
:
/home/brooks8/bin/mylib/include/include/util.h:14:21: fatal error: hwloc.h: No such file or directory
#include <hwloc.h>
^
Is there a way to solve this issue without needing to link hwloc when I use my library?
Thank you in advance, and please let me know if I should provide any more information regarding my situation.