I have an C++ project in Eclipse that uses Autoconf and Automake. My (simplified) project structure is the following:
+-- Makefile.am
+-- configure.ac
+-- src/
| +-- 4Bench.cpp
| | +-- Makefile.am
| | +-- folder1/
| | | +-- ...
| | +-- folder2/
| | | +-- ...
| | +-- folder3/
| | | +-- ...
+-- include/
| +-- ...
The folder src/ will contain multiple binaries (4Bench.cpp is one of them) that will use the .cpp files located in folder1, folder2, etc. All the header files are located in include/. My src/Makefile.am looks as follows:
bin_PROGRAMS=4Bench
4Bench_SOURCES=4Bench.cpp folder1/file11.cpp folder2/file21.cpp ...
4Bench_CPPFLAGS=-I$(top_srcdir)/include
AM_CPPFLAGS=$(BOOST_CPPFLAGS)
AM_LDFLAGS=$(BOOST_LDFLAGS)
4Bench_LDADD=$(BOOST_PROGRAM_OPTIONS_LIB)
Since I expect to have many files in the subfolders of src/, I want to use wildcards to have something like:
4Bench_SOURCES=4Bench.cpp $(wildcard folder1/*.cpp) $(wildcard folder2/*.cpp) $(wildcard folder3/*.cpp)
Unfortunately this leads to a bunch of errors of the form "undefined reference", that is, the compiler cannot find the implementation of the classes in the .cpp files. Enumerating every single file that is required by the binary works. For further reference I provide both the ./configure.ac and ./Makefile.am files.
AC_PREREQ(2.59)
AC_INIT(4Bench, 0.1)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects -Wno-portability])
AC_PROG_CXX
AC_CONFIG_MACRO_DIR([m4])
AX_CXX_COMPILE_STDCXX_11
AX_BOOST_BASE([1.32],,[AC_MSG_ERROR([4Bench needs Boost, but it was not found in your system])])
AX_BOOST_PROGRAM_OPTIONS
AX_BOOST_UNIT_TEST_FRAMEWORK
AC_CONFIG_FILES(Makefile src/Makefile test/Makefile)
AC_OUTPUT
SUBDIRS=src test
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
EXTRA_DIST = bootstrap
Any ideas about how to solve the issue? I am using Linux Mint 18 with g++ 5.4.0, autoconf 2.69 and GNU automake 1.15. Thanks for your attention & help!
Any ideas about how to solve the issue?
You can't do that with the current implementation of automake
. This is a feature.