我正在运行 Linux,Ubuntu 10.04。
这不是我第一次尝试使用自动工具。我做了很多研究并遵循了很多教程:这是我想做的,我尝试过的以及我面临的问题。
目标:
- 编译(然后交叉编译,但这将是另一项工作)我自己的库,使用 libtool、autoconf 和 automake 用 C 编码
我尝试了什么以及我在哪里:
库名称为 FXPLib,包名称为 libfxplib-0.1
我的项目文件夹是:
Makefile.am (the only one) include include/fxplib.h (main header) include/FXPLib include/FXPLib/header1.h (these are public headers) include/FXPLib/header2.h include/FXPLib/... src src/sub1/file1.c src/sub2/file1.c src/sub3 ...
我运行了自动扫描,得到了一个 configure.ac,在这里进行了编辑:
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) AC_INIT([libfxplib-0.1], [0.1], [<>]) AC_CONFIG_SRCDIR([src/object_system/FXP_image_s.h]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE AM_PROG_LIBTOOL LT_PREREQ([2.2]) LT_INIT # Checks for programs. AC_PROG_CC AC_PROG_MAKE_SET # Checks for libraries. # Checks for header files. AC_CHECK_HEADERS([stdlib.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS([memset]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT
我这样写 Makefile.am :
lib_LTLIBRARIES = libfxplib-0.1.la libfxplib_0_1_la_CFLAGS = -I$(srcdir)/include -I$(srcdir)/include/FXPLib `sdl-config --cflags --libs` -lSDL_image libfxplib_0_1_la_SOURCES = src/sub1/file1.c \ src/sub1/file2.c \ src/sub2/file1.h \ ... nobase_include_HEADERS = include/fxplib.h \ include/FXPLib/header1.h \ include/FXPLib/header2.h \ ... ACLOCAL_AMFLAGS = -I m4
- 然后我运行aclocal和autoheader来获取 automake 需要的文件
- 然后最重要的:autoconf
- 并且:automake --add-missing --copy
从那里开始,一切都很好。但后来我尝试编译:
$ ./configure
一切都还好...
$ make
然后我得到:
...
src/graphics_engine/FXP_rendering.c:35:25: error: FXP_image_s.h: File not found
...
在哪里 :
- "graphics_engine"相当于src/ sub
- “FXP_rendering.c”到src/sub/ file.c
- “FXP_image_s.h”到src/sub2/ header.h
这意味着:automake 可以编译子目录中的 .c 文件,但不能在这些文件中包含位于其他子目录中的私有 .h 文件。
我的问题是:如何告诉 automake 编译每个子目录中的每个文件,就好像它们都在同一个地方一样?
我希望我是可以理解的(对于您在我的话中发现的一些问题,我很抱歉,因为我是法国人)
提前谢谢你。