I would like to edit an existing software to add a new source file (Source.cpp).
But, I can't manage the compilation process (it seems to be automake and it looks very complicated).
The software (iperf 2: https://sourceforge.net/projects/iperf2/files/?source=navbar) is compiled using a classical
Settings.cpp:(.text+0x969) : undefined reference to ...
This project is built with the autotools, as you already figured out.
The makefiles are built by automake. It takes its input in files that usually have a
am file name extension.
The iperf program is built by the makefile generated from
src/Makefile.am. This is indicated by:
bin_PROGRAMS = iperf
All (actually this is a simplification, but which holds in this case) source files of a to be built binary are in the corresponding name_SOURCES variable, thus in this case
iperf_SOURCES. Just add your source file to the end of that list, like so (keeping their formatting):
iperf_SOURCES = \ Client.cpp \ # lines omitted tcp_window_size.c \ my_new_file.c
Now, to reflect this change in any future generated
src/Makefile you need to run automake. This will modify
src/Makefile.in, which is a template that is used by
config.sub at the end of
configure to generate the actual makefile.
Running automake can happen in various ways:
If you already have makefiles that were generated after an configure these should take care of rebuilding themselves. This seems to fail sometimes though!
You could run automake (in the top level directory) by hand. I've never done this, as there is the better solution to...
autoreconf --install (possibly add
--force to the arguments) in the top level directory. This will regenerate the entire build system, calling all needed programs such as autoheader, autoconf and of course automake. This is my favorite solution.
The later two options require calling configure again, IMO ideally doing an out of source built:
# in top level dir mkdir build cd build ../configure # arguments make # should now also compile and link your new source file