【发布时间】:2011-07-14 05:47:52
【问题描述】:
我正在运行 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 编译每个子目录中的每个文件,就好像它们都在同一个地方一样?
我希望我是可以理解的(对于您在我的话中可能发现的一些问题,我深表歉意,因为我是法国人)
提前谢谢你。
【问题讨论】:
-
你在这里有一个很好的格式化和详细的问题,太糟糕了,我不能帮你回答。
-
谢谢。这是一个非常具体的问题:我应该尝试将其发布在“专家程序员”stackexchange 网站上吗?
-
好吧!明天会有更多人登录时,有什么办法可以将这个帖子“上线”?
标签: gcc makefile compilation autotools libtool