4

我正在尝试将 libcs​​v 转换为使用 libtool,这样我就可以在 mac os x 上使用它而不会破坏 makefile。当我尝试运行从工具生成的 makefile 时,出现以下错误:

~/software/libcsv (gnu_tools) $ make 
tag=CC   --mode=compile gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libcsv\" 
-DVERSION=\"3.0.1\" -I.     -g -O2 -MT libcsv.lo -MD -MP -MF .deps/libcsv.Tpo -c -o libcsv.lo  
libcsv.c
/bin/sh: --mode=compile: command not found
make: [libcsv.lo] Error 127 (ignored)
mv -f .deps/libcsv.Tpo .deps/libcsv.Plo
mv: rename .deps/libcsv.Tpo to .deps/libcsv.Plo: No such file or directory
make: *** [libcsv.lo] Error 1

我正在运行 OS X 10.5。因此,经过一番搜寻后,我注意到生成的 makefile 有一个空的 libtool var:

<generated makefile>
LD = 
LDFLAGS = 
LIBOBJS = 
LIBS = 
LIBTOOL = 
LIPO = 
LN_S = 
LTLIBOBJS = 
<more generated makefile>

如果我将 LIBTOOL 设置为 libtool,那么一切都很好。我假设我在下面的 autoconf 或 automake 文件中犯了一个错误:

Makefile.am
lib_LTLIBRARIES = libcsv.la
libcsv_la_SOURCES = libcsv.c
include_HEADERS = csv.h
libcsv_la_LDFLAGS = -version-info 3:1:0
ACLOCAL_AMFLAGS = -I m4

configure.ac
dn1 Process this file with autoconf to produce a configure script.
AC_INIT(libcsv.c)
AM_INIT_AUTOMAKE(libcsv, 3.0.1)
AC_PROG_CC
AC_OUTPUT(Makefile)
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AC_CHECK_FUNCS([strerror])
AC_FUNC_MALLOC
C_PROG_RANLIB
AC_PROG_CXX
LT_INIT
LT_OUTPUT
AC_TYPE_SIZE_T

如果有任何帮助,这里是 config.log 的一部分:

## ------------------ ##
## Running config.lt. ##
## ------------------ ##
config.lt:680: creating libtool
configure:17115: checking for size_t
configure:17115: gcc -c -g -O2  conftest.c >&5
configure:17115: $? = 0
configure:17115: gcc -c -g -O2  conftest.c >&5
conftest.c: In function 'main':
conftest.c:62: error: syntax error before ')' token
configure:17115: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libcsv"
| #define VERSION "3.0.1"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define HAVE_STRERROR 1
| #define HAVE_STDLIB_H 1
| #define HAVE_MALLOC 1
| /* end confdefs.h.  */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| #  include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| #  include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| if (sizeof ((size_t)))
|       return 0;
|   ;
|   return 0;
| }
configure:17115: result: yes

那么有谁知道我做错了什么?

提前致谢。

4

3 回答 3

7

我没有给你一个明确的答案,但我建议的第一件事是把你放在你AC_OUTPUT的末尾configure.ac,在LT_INIT. 并非完全这么简单,但是将 的内容configure.ac依次扩展为依次执行的 shell 脚本片段也没有太大的错误。如果您Makefile在找到之前发出配置libtool,那么这可以解释LIBTOOL为空。

您的一个相当传统的布局configure.ac如下:

dnl Process this file with autoconf to produce a configure script.
AC_INIT(libcsv.c)
AM_INIT_AUTOMAKE(libcsv, 3.0.1)
AC_CONFIG_MACRO_DIR([m4])

dnl find programs
AC_PROG_CC
AC_PROG_CXX
LT_INIT
AC_PROG_RANLIB

dnl check functionality
AC_CHECK_FUNCS([strerror])
AC_FUNC_MALLOC
AC_TYPE_SIZE_T

AC_OUTPUT(Makefile)

我认为您不需要LT_OUTPUT,并且文档指出这AC_PROG_LIBTOOL是已弃用的同义词LT_INIT(因此两者兼有可能是自找麻烦)。

(没什么特别的,请注意 OS X 有一个名为 的命令libtool,这与 GNU Libtool 无关。我很确定这不是你的问题,但这是一个让人们感到困惑的问题)

于 2010-07-12T20:19:10.197 回答
1

您可以尝试通过运行重新执行 libtool 集成libtoolize --force(我在不同主机上使用不同的不兼容 libtool 版本时遇到了很多麻烦, libtoolize --force 在这种情况下有很大帮助)。还要注意 libtool 消息的配置输出,它们必须是这样的:

checking if libtool supports shared libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
appending configuration tag "F77" to libtool

特别是该configure: creating libtool行必须出现在输出中。

于 2010-07-07T10:40:40.720 回答
0

我的 configure.ac 只有:

LT_INIT([dlopen])
AC_SUBST([LIBTOOL_DEPS])

LT_OUTPUT 用于在 configure 本身中使用 libtool 进行以后的测试,并且需要 config.lt 来进行设置。我从来没有使用过它,所以我不知道这意味着什么,但是把这条线拿出来看看是否能解决你的问题并没有什么坏处。

于 2010-07-12T13:25:50.097 回答