转换为libtool时automake和autoconf找不到libtool

发布于 2024-09-07 22:47:41 字数 3513 浏览 2 评论 0原文

我正在尝试将 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

那么有人知道我做错了什么吗?

提前致谢。

I'm trying to convert libcsv to use libtool so I can use it on mac os x without mangling the makefile. When I try to run the makefile generated from the tools I get the following error:

~/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

I'm running OS X 10.5. So after a little fossicking about I noticed that the makefile generated has an empty libtool var:

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

If I set LIBTOOL to libtool, then all is well. I assume I've made a mistake in my autoconf or automake files which are below:

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

If it's any help here is part of the 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

So does anyone know what I've done wrong?

Thanks in advance.

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

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

发布评论

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

评论(3

可是我不能没有你 2024-09-14 22:47:41

我没有给你一个明确的答案,但我建议的第一件事是将你的 AC_OUTPUT 放在 configure.ac 的末尾,在 之后LT_INIT。虽然并不完全如此简单,但将 configure.ac 的内容视为依次扩展为依次执行的 shell 脚本片段也并不算大错。如果您在找到 libtool 之前发出已配置的 Makefile,则可以解释 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,并且 docs 请注意,AC_PROG_LIBTOOLLT_INIT 的已弃用同义词(所以两者兼而有之可能是自找麻烦)。

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

I dont have a definite answer for you, but the first thing I'd suggst is to put your AC_OUTPUT at the end of your configure.ac, after the LT_INIT. It's not completely this simple, but it's not far wrong to think of the contents of configure.ac as expanding in turn to fragments of shell script that are executed in turn. If you emit the configured Makefile before you've found libtool, then that could explain LIBTOOL being empty.

A fairly conventional layout of your configure.ac would be the following:

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)

I don't think you needed LT_OUTPUT, and the docs note that AC_PROG_LIBTOOL is a deprecated synonym for LT_INIT (so having both is probably asking for trouble).

(Apropos of nothing very much, note that OS X has a command called libtool, which is nothing to do with GNU Libtool. I'm pretty sure that's not your problem here, but it's a gotcha that's confused people before)

箜明 2024-09-14 22:47:41

您可以尝试通过运行 libtoolize --force 来重新强制 libtool 集成(我在不同主机上遇到了很多不兼容的 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: 创建 libtool 行必须出现在输出中。

You can try to re-enforce the libtool integration by running libtoolize --force (I had a lot of trouble with different incomatible libtool versions on different hosts, libtoolize --force helps a lot in such cases). Also watch out the configure output for libtool messages, they must read like this:

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

especially the configure: creating libtool line must be present in the output.

睡美人的小仙女 2024-09-14 22:47:41

我的configure.ac只有:

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

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

My configure.ac just has:

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

The LT_OUTPUT is for using libtool for later tests within configure itself, and requires a config.lt to set things up. I've never had to use it, so I don't know all that entails, but it can't hurt to take that line out and see if that fixes your issue.

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