Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Automake cannot build objects without an explicit target (program, library) that will use these objects. One reason is that compilation options are specified per-target. If two targets, e.g. two binaries use the same object but have different compilation option, the same object may have to be compiled twice.</p> <p>You have three ways to do what you want, they all involve tying your source files to some target.</p> <ol> <li><p>Do not use a <code>src/ctrnn/Makefile.am</code>, just make reference to the subdirectory source files from your <code>src/Makefile.am</code>: <pre> bin_PROGRAMS = foo foo_SOURCES = main.c crtnn/network.cpp crtnn/neuron.cpp </pre> Note that this will build <code>network.o</code> and <code>neuron.o</code> in the same directory as <code>main.o</code>. If you want objects in subdirectories, use <code>AUTOMAKE_OPTIONS = subdir-objects</code>.</p></li> <li><p>Use a convenience library. In <code>src/crtnn/Makefile.am</code> make a library of your two objects:<pre> noinst_LIBRARIES = libcrtnn.a libcrtnn_a_SOURCES = network.cpp neuron.cpp </pre> and in <code>src/Makefile.am</code>, link your executable to the library:<pre> bin_PROGRAMS = foo foo_SOURCES = main.c foo_LDADD = crtnn/libcrtnn.a SUBDIRS = crtnn </pre> It's called "convenience" when it is not going to be installed (you can tell because of the <code>noinst_</code> prefix): it is just used during the build. And this is a static library, so the result is the same as if you had replaced <code>crtnn/libcrtnn.a</code> by <code>crtnn/network.o</code> and <code>crtn/neuro.o</code> when linking <code>foo</code>.</p></li> <li><p>Use a Libtool convenience library. This requires more setup if you are not using Libtool already. You should add a call <code>LT_INIT</code> in <code>configure.ac</code> and rerun <code>autoreconf</code> to install the libtool files. Then you can update <code>src/crtnn/Makefile.am</code> to make a library of your two objects as follows:<pre> noinst_LTLIBRARIES = libcrtnn.la libcrtnn_la_SOURCES = network.cpp neuron.cpp </pre> and <code>src/Makefile.am</code> as follows:<pre> bin_PROGRAMS = foo foo_SOURCES = main.c foo_LDADD = crtnn/libcrtnn.la SUBDIRS = crtnn </pre> What is the difference? you may ask, almost none. One advantage of using Libtool convenience libraries is that they can be nested: a Libtool library can include another Libtool library (this is convenient when you have a deep hierarchy of source code and you are building a library at each level). Also Libtool convenience libraries can be used to build a shared library if you want. Automake's static libraries cannot.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload