The errors you got with missing #include <cstring>
and #include <memory>
is mainly du to a cleanup that happened in GNU headers: inclusion of unnecessary headers were removed and consequently programs not including the proper headers for the features they use face compiling errors.
About HAVE_SDL_H
, most likely, your Linux distribution is missing packages.
You probably need to install the SDL library. Some Linux distributions like Ubuntu split the packages between the library runtime and the dev files so you need to install both packages
sudo apt-get install libsdl1.2-dev
Regarding:
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -O3 -ffast-math -funroll-all-loops -g -O2 -I/usr/include -I/usr/local/include -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -MT tick.o -MD -MP -MF ".deps/tick.Tpo" -c -o tick.o tick.cpp; \
then mv -f ".deps/tick.Tpo" ".deps/tick.Po"; else rm -f ".deps/tick.Tpo"; exit 1; fi
tick.cpp:144:5: error: #error "no timer implemented for your plateform"
It indeed fails to compile because HAVE_SDL_H
is not defined in config.h
. When you look at configure.in
you see it's using AC_CHECK_HEADERS([SDL.h])
From the autoconf manual:
— Macro: AC_CHECK_HEADERS (header-file..., [action-if-found], [action-if-not-found], [includes])
For each given system header file header-file in the blank-separated argument list that exists, define HAVE_header-file (in all capitals). If action-if-found is given, it is additional shell code to execute when one of the header files is found. You can give it a value of ‘break’ to break out of the loop on the first match. If action-if-not-found is given, it is executed when one of the header files is not found.
So, AC_CHECK_HEADERS([SDL.h])
makes configure search for SDL.h
in /usr/include
and doesn't find it because its (new?) path is /usr/include/SDL/SDL.h
As a workaround, use CPPFLAGS
to add system header search paths when invoking configure:
./configure CPPFLAGS="-I/usr/include/SDL"
Now you may want to fix configure.in
configure.in
uses AM_PATH_SDL(1.2.0)
which will end up invoking sdl-config --cflags
to define SDL_CFLAGS
. (the implementation of AM_PATH_SDL
typically lies in the /usr/share/aclocal/sdl.m4
file)
# Check for SDL
AM_PATH_SDL(1.2.0)
LDFLAGS="$LDFLAGS $SDL_LIBS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
AC_CHECK_HEADERS([SDL.h])
AC_LANG_CPLUSPLUS
sdl-config --cflags
returns -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
but those -I
and -D
directives should not end up in CFLAGS
anyway but rather in CPPFLAGS
(as per the autoconf manual). Hence I would say there is already something wrong "at the SDL level".
Now take a look at the AC_LANG
documentation:
‘C’
Do compilation tests using CC and CPP and use extension .c for test programs. Use compilation flags: CPPFLAGS with CPP, and both CPPFLAGS and CFLAGS with CC.
‘C++’
Do compilation tests using CXX and CXXCPP and use extension .C for test programs. Use compilation flags: CPPFLAGS with CXXCPP, and both CPPFLAGS and CXXFLAGS with CXX.
Moving the AC_LANG_CPLUSPLUS
up so that it at least above AC_CHECK_HEADERS([SDL.h])
should make it now use g++
and CXXFLAGS
when trying to compile SDL.h
which should success since SDL_CFLAGS
were added to CXXFLAGS
. (again, it should really be SDL_CPPFLAGS
but you won't change SDL...)
Best Answer
The way the Autotools are designed, a package author doesn't have to do anything to support prerequisite installed in non-standard locations. The output of
./configure --help
includes the following lines:Therefore, if the installer has a prerequisite installed in a non standard location, he will have to issue
Because
CPPFLAGS
andLDFLAGS
are used byconfigure
checks andMakefile
rules, everything should work.Some package authors like to offer a
--with-
package=location
option as a shorthand for the above, but this normally is not the purpose of--with-
package options. These options are better used to specify whether an optional package should be used, or how a prerequisite should be fulfilled.