2

With Automake you can build a shared library (.so) like this:

lib_LTLIBRARIES = libyeah.la
libyeah_la_SOURCES = yeah.c

Then libyeah.so is installed to $(libdir) with make install.

When you specify the noinst_ prefix (instead of lib_) to avoid installing the library, it's not built as a shared object (only an archive, .a). It seems that the library is never actually linked.

I need a shared object, without installing it, for project tests (a test plugin which is dynamically loaded by the test program).

I tried to add -module and -shared to libyeah_la_LDFLAGS without success.

eepp
  • 7,255
  • 1
  • 38
  • 56
  • Possible duplicate of [Automake: building shared module which is not to be installed](https://stackoverflow.com/questions/8277478/automake-building-shared-module-which-is-not-to-be-installed) – Akash Rawal May 31 '17 at 19:25

1 Answers1

0

You can bypass the default libdir and install it in some other directory instead of /usr/local/lib:

make DESTDIR=/home/user/staging install

will install your lib in /home/user/staging/usr/local/lib (if you used the default --prefix at configure time). Then (on Linux -- you didn't specify what your underlying platform is) you can:

LD_LIBRARY_PATH=/home/user/staging/usr/local/lib test_libyeah

to run your test.

ldav1s
  • 15,885
  • 2
  • 53
  • 56
  • 1
    I might be splitting hairs, but the questions was *"how to build shared library without installing it"*. Presumably so `make install` does not install it. Your answer shows how to install it somewhere else, which is a different question. – jww Nov 04 '17 at 22:37