编译 cal3d 演示“cally” (带有骨骼动画的 3D 模型库)

发布于 2024-08-17 01:02:25 字数 2459 浏览 7 评论 0原文

我认为这是一个关于automake的问题。

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

我正在努力处理 cally 演示Cal3D。 我遇到的第一个问题是 Cal3D 代码库缺失 #include#include 在很多地方

每次我在 Cal3d 中的任何源文件中出现错误时执行此操作就足以让我编译它。

cally 演示还需要一些 #include

现在我的问题是编译 tick.cpp 时未定义 HAVE_SDL_H 。 配置和 makefile 似乎接受 SDL 安装在我的系统上,但 src/tick.cpp 中的宏不接受。

我猜想configure.in 中存在某种错误或其他错误,但我似乎不知道它是什么。

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"

编辑:

我终于编译了演示。

当我编译 cal3d 时,我将 #include 添加到以下文件中:

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

当我编译 cally 时,我将 #include 添加到以下文件中:

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

model.cpp 我将第 640 行更改为

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

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

我还做了一些更丑陋的更改来编译src/tick.cpp

在 src/tick.cpp 中,我删除了与 SDL 有关的所有内容。我还删除了检查 __i386__ 或 __ia64__ 的宏 if 子句,以便 Tick::getTime() 也可以编译。

我知道这不是一个正确的解决方案,因此非常欢迎改进。

  • 64 位 OpenSuSE,内核为 2.6.27。
  • GCC:4.3.2
  • GNU Automake:1.10.1
  • GNU Autoconf 2.63
  • 64 位版本的 SDL 库与 zypper 一起安装(通过 GUI)。

解决方案

configure.in中更改

AC_CHECK_HEADERS([SDL.h])

AC_CHECK_HEADERS([SDL/SDL.h])

(然后运行autoreconf和./configure)

tick.cpp中更改HAVE_SDL_H<的所有检查/code> 到 HAVE_SDL_SDL_H

这都是由于 sdl 库的重组所致。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

私藏温柔 2024-08-24 01:02:25

缺少 #include#include 时出现的错误主要是由于 GNU 标头中发生的清理造成的:包含不必要的标头已删除,因此不包含其使用的功能的正确标头的程序会面临编译错误。

关于 HAVE_SDL_H,很可能您的 Linux 发行版缺少软件包。

您可能需要安装 SDL 库。一些 Linux 发行版(例如 Ubuntu)将库运行时和开发文件之间的软件包分开,因此您需要安装这两个软件包

sudo apt-get install libsdl1.2-dev

关于:

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"

它确实无法编译,因为 HAVE_SDL_H 未在 config.h 中定义。当您查看 configure.in 你看到它使用 AC_CHECK_HEADERS([SDL.h])

来自 autoconf 手册

— 宏:AC_CHECK_HEADERS(头文件...、[找到时执行操作]、[未找到时执行操作]、[包含])

对于存在的空白分隔参数列表中的每个给定系统头文件 header-file,定义 HAVE_header-file (全部大写)。如果给出了 action-if-found ,则当找到头文件之一时要执行额外的 shell 代码。您可以为其指定“break”值,以在第一个匹配时跳出循环。如果给出了action-if-not-found,则当未找到头文件之一时执行该操作。

因此,AC_CHECK_HEADERS([SDL.h]) 使配置在 /usr/include 中搜索 SDL.h,但没有找到它,因为它的(新的?)路径是 /usr/include/SDL/SDL.h

作为解决方法,请在调用配置时使用 CPPFLAGS 添加系统标头搜索路径:

./configure CPPFLAGS="-I/usr/include/SDL"

现在您可能想要修复 configure.in

configure.in 使用 AM_PATH_SDL (1.2.0) 最终将调用 sdl-config --cflags 来定义 SDL_CFLAGS。 (AM_PATH_SDL 的实现通常位于 /usr/share/aclocal/sdl.m4 文件中)

# 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 返回 < code>-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT 但这些 -I-D 指令不应以 结尾CFLAGS 无论如何,而是在 CPPFLAGS 中(根据 autoconf 手册)。因此我想说“在 SDL 级别”已经出现了问题。

现在看一下 AC_LANG 文档< /a>:

“C”

使用CC和CPP进行编译测试,并使用扩展名.c作为测试程序。使用编译标志:CPPFLAGS 与 CPP 一起使用,CPPFLAGS 和 CFLAGS 与 CC 一起使用。

'C++'

使用 CXX 和 CXXCPP 进行编译测试,并使用扩展名 .C 作为测试程序。使用编译标志:CPPFLAGS 与 CXXCPP 一起使用,CPPFLAGS 和 CXXFLAGS 与 CXX 一起使用。

AC_LANG_CPLUSPLUS 向上移动,使其至少高于 AC_CHECK_HEADERS([SDL.h]) 应该使其现在使用 g++CXXFLAGS 尝试编译 SDL.h 时应该会成功,因为 SDL_CFLAGS 已添加到 CXXFLAGS 中。 (再说一遍,它确实应该是 SDL_CPPFLAGS 但您不会更改 SDL...)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文