user164384
user164384

Reputation: 1

Automake ignores multiple source files for building a library

I am trying to create a static library with autotools however it only takes the cpp file with the same name of the library and ignores the other source files.

Makefile.am

AM_CXXFLAGS=-std=c++11
lib_LIBRARIES = mylib.a
mylib_a_SOURCES = dep1.cpp dep2.cpp mylib.cpp

automake and make do not complain but it only compiles mylib.cpp and turns it into a library. When I try to link against it I get errors such as

dep1.cpp undefined reference to dep1::method_name

Please help. I have been banging my head against the keyboard for hours. There are no tutorials on making libraries. The only autotool documentation I can find is either a 5 line hello world examples or 5000 page books with zero examples or context.

Upvotes: 0

Views: 208

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22519

You are naming the _SOURCES variable incorrectly. You want:

libmylib_a_SOURCES = ...

See the node in the Automake manual titled "Building a library"... this is in the first example.

I'm slightly surprised that Automake didn't give you a warning about a _SOURCES variable not corresponding to a known object.

Upvotes: 1

Related Questions