Take the 2-minute tour ×

I'm creating a software project and I wanted to use autotools to do the makefile and etc. script generation for me, I manually created Makefile.am and configure.in files, and I'm using the autogen.sh script from here. The problem comes when attempting to build the project in a separate 'build' directory, e.g. if I go:

mkdir build
cd build

The configure step works fine, but when running make I get:

make  all-recursive
Making all in src
/bin/sh: line 0: cd: src: No such file or directory
make: *** [all] Error 2

Any tips to get this working? Or should I give up and try something simpler/different. I plan for this to be a reasonably simple C++ project, and the only dependency I plan to have is on the boost unit testing framework, and to do most development in Eclipse IDE.

share|improve this question
this seems to be a problem with your Makefile.am's. it would be great if you could post them (at least the Makefile.am in your project's root and src (assuming that src/ is directly in the project-root) –  umläute Sep 10 '12 at 9:28
Sorry.. Here they are gist.github.com/3690227 –  Adam M-W Sep 10 '12 at 10:39

1 Answer 1

up vote 1 down vote accepted

there's a bug in your src/Makefile.am, line#17:

swin-adventure_SOURCES = src/main.cc

should really read:

swin-adventure_SOURCES = main.cc

since you are already in the src/ directory (unless there's a src/src/ subfolder)

there's another bug, as you are using special characters in your _SOURCES variabes: swin-adventure_SOURCES has the forbidden - character; try to normalize that to swin_adventure_SOURCES

finally, you are trying to assign a value to bin_PROGRAMS multiple times (and each time the same value), try to avoid that.

something like:

## Additional flags to pass to aclocal when it is invoked automatically at
## make time. The ${ACLOCAL_FLAGS} variable is picked up from the environment
## to provide a way for the user to supply additional arguments.

## Define an executable target "swin-adventure", which will be installed into the
## directory named by the predefined variable $(bindir).
bin_PROGRAMS = swin-adventure

## Define the list of source files for the "swin-adventure" target. The file 
## extension .cc is recognized by Automake, and causes it to produce rules 
## which invoke the C++ compiler to produce an object file (.o) from each 
## source file. The ## header files (.h) do not result in object files by 
## themselves, but will be included in distribution archives of the project.
swin_adventure_SOURCES = main.cc
share|improve this answer
Thanks. You've been a real help. Is there a way to move where the generated binary is created (i.e. create it in the root directory rather than the src directory?) –  Adam M-W Sep 10 '12 at 14:18
usually you don't :-). if you absolutely need it to be in the root directory you could either add all the build-info into your root Makefile.am (rather than src/Makefile.am), this time using src/main.cc (isn't this where we came in?); or you add a post-build hook that copies/symlinks the resulting binary to the place you want –  umläute Sep 26 '12 at 9:14

Your Answer


