tags:

views:

202

answers:

1

Hi!

I think this is a question about automake.

http://home.gna.org/cal3d/

I'm struggling with the cally demo of Cal3D. The first problem I ran into was that the Cal3D code base is missing #include <cstring> and #include <memory> in a lot of places.

Doing this every time I got an error in any source file in Cal3d was enough to let me compile it.

The cally demo also needed some #include <cstring>

Now my problem is that HAVE_SDL_H is not defined when tick.cpp is compiled. The configure and makefile seems to accept that SDL is installed on my system, but the macros in src/tick.cpp doesn't.

I guess there is some kind of bug in the configure.in or something, but I don't seem to find out just what it is.

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"

Edit:

I've finally compiled the demo.

When I compiled cal3d I added #include <cstring> to the following files:

  • src/cal3d/hardwaremodel.cpp
  • src/cal3d/platform.cpp
  • src/cal3d/renderer.cpp
  • src/cal3d/submesh.cpp
  • src/cal3d_converter.cpp

When I compiled cally I added #include <cstring> to the following files:

  • src/demo.cpp
  • src/model.cpp

In model.cpp I changed line 640 from

glBindTexture(GL_TEXTURE_2D, (GLuint)pCalRenderer->getMapUserData(0));

to

glBindTexture(GL_TEXTURE_2D, *(GLuint*)pCalRenderer->getMapUserData(0));

I also did some uglier changes to get src/tick.cpp to compile.

In src/tick.cpp I removed everything that had anything to do with SDL. I also removed a macro if clause checking for __i386__ or __ia64__, so that Tick::getTime() could also be compiled.

I know that this is not a proper fix, so improvements are very much welcome.

  • 64-bit OpenSuSE with a 2.6.27 kernel.
  • GCC: 4.3.2
  • GNU Automake: 1.10.1
  • GNU Autoconf 2.63
  • 64-bit versions of the SDL library is installed with zypper (through the GUI).

Solution

In configure.in change

AC_CHECK_HEADERS([SDL.h])

to

AC_CHECK_HEADERS([SDL/SDL.h])

(then run autoreconf and ./configure)

in tick.cpp change all checks for HAVE_SDL_H to HAVE_SDL_SDL_H

This is all due to a restructuring in the sdl library.

+2  A: 

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...)

Gregory Pakosz
HAVE_SDL_H is still a big mystery to me. The sdl packages were already installed...
Styggentorsken
well the m4 macro in sdl.m4 must be broken on your version?
Gregory Pakosz
my sdl.m4 is identical to what is pasted into aclocal.m4 in the cally folder. Unless I somehow produced the aclocal.m4, I am using the same sdl.m4 as the author of the cally project.
Styggentorsken
whoops, it seems like I have produced it... there are some differences...
Styggentorsken
getting close...a detail that I should have added is that that configure complains about not finding SDL.h, but not about SDL/SDL.h, but I still didn't get the right macro, I guess I have to change it to check for HAVE_SDL_SDL_H
Styggentorsken
what's inside aclocal.m4 comes from /usr/share/local/sdl.m4 -- see http://www.lrde.epita.fr/~adl/autotools.html to understand how the autotools interact with each other and with which files
Gregory Pakosz
hmm, does `./configure CPPFLAGS="-I/usr/include/SDL"` work? that would avoid hacking the files
Gregory Pakosz
yes it does :-)I think it is the most elegant temporary fix, but not one that should make into their repository.
Styggentorsken
The fix would be trying moving up `AC_LANG_CPLUSPLUS`, I edited the answer again to explain what's going on
Gregory Pakosz
configure leaves me with the warningconfigure: WARNING: SDL.h: accepted by the compiler, rejected by the preprocessor!configure: WARNING: SDL.h: proceeding with the compiler's result - but it compiles without warnings
Styggentorsken
and in the end, do you have `HAVE_SDL_H` in `config.h`?
Gregory Pakosz
yes, it's there
Styggentorsken