2

错误

当我尝试在 OS X 上为基于 autotools 的项目执行 make 时收到以下错误:

libtool: link: unsupported hardcode properties
libtool: link: See the libtool documentation for more information.
libtool: link: Fatal configuration error.

make 调用 libtool 如下:

/bin/sh ./libtool  --tag=CXX   --mode=link clang++  -g <blah blah blah>

调查

我已将问题范围缩小到使用 CXX 标签。出于某种原因,libtool 脚本(通过运行 ./configure 生成 libtoolize 等)输出 CXX 配置,如下所示:

# ### BEGIN LIBTOOL TAG CONFIG: CXX

# The linker used to build libraries.
LD=""

# How to create reloadable object files.
reload_flag=""
reload_cmds=""

# Commands used to build an old-style archive.
old_archive_cmds=""

# A language specific compiler.
CC=""

# Is the compiler the GNU compiler?
with_gcc=

# Compiler flag to turn off builtin functions.
no_builtin_flag=""

# Additional compiler flags for building library objects.
pic_flag=""

# How to pass a linker flag through the compiler.
wl=""

# Compiler flag to prevent dynamic linking.
link_static_flag=""

# Does compiler simultaneously support -c and -o options?
compiler_c_o=""

# Whether or not to add -lc for building shared libraries.
build_libtool_need_lc=

# Whether or not to disallow shared libs when runtime libs are static.
allow_libtool_libs_with_static_runtimes=

# Compiler flag to allow reflexive dlopens.
export_dynamic_flag_spec=""

# Compiler flag to generate shared objects directly from archives.
whole_archive_flag_spec=""

# Whether the compiler copes with passing no objects directly.
compiler_needs_object=""

# Create an old-style archive from a shared archive.
old_archive_from_new_cmds=""

# Create a temporary old-style archive to link instead of a shared archive.
old_archive_from_expsyms_cmds=""

# Commands used to build a shared archive.
archive_cmds=""
archive_expsym_cmds=""

# Commands used to build a loadable module if different from building
# a shared archive.
module_cmds=""
module_expsym_cmds=""

# Whether we are building with GNU ld or not.
with_gnu_ld=""

# Flag that allows shared libraries with undefined symbols to be built.
allow_undefined_flag=""

# Flag that enforces no undefined symbols.
no_undefined_flag=""

# Flag to hardcode $libdir into a binary during linking.
# This must work even if $libdir does not exist
hardcode_libdir_flag_spec=""

# Whether we need a single "-rpath" flag with a separated argument.
hardcode_libdir_separator=""

# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
# DIR into the resulting binary.
hardcode_direct=

# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
# DIR into the resulting binary and the resulting library dependency is
# "absolute",i.e impossible to change by setting ${shlibpath_var} if the
# library is relocated.
hardcode_direct_absolute=

# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
# into the resulting binary.
hardcode_minus_L=

# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
# into the resulting binary.
hardcode_shlibpath_var=

# Set to "yes" if building a shared library automatically hardcodes DIR
# into the library and all subsequent libraries and executables linked
# against it.
hardcode_automatic=

# Set to yes if linker adds runtime paths of dependent libraries
# to runtime path list.
inherit_rpath=

# Whether libtool must link a program against all its dependency libraries.
link_all_deplibs=

# Set to "yes" if exported symbols are required.
always_export_symbols=

# The commands to list exported symbols.
export_symbols_cmds=""

# Symbols that should not be listed in the preloaded symbols.
exclude_expsyms=""

# Symbols that must always be exported.
include_expsyms=""

# Commands necessary for linking programs (against libraries) with templates.
prelink_cmds=""

# Commands necessary for finishing linking programs.
postlink_cmds=""

# Specify filename containing input files.
file_list_spec=""

# How to hardcode a shared library path into an executable.
hardcode_action=

# The directories searched by this compiler when creating a shared library.
compiler_lib_search_dirs=""

# Dependencies to place before and after the objects being linked to
# create a shared library.
predep_objects=""
postdep_objects=""
predeps=""
postdeps=""

# The library search path used internally by the compiler when linking
# a shared library.
compiler_lib_search_path=""

# ### END LIBTOOL TAG CONFIG: CXX

如您所见,一切都是空白的。所以 libtool 脚本很糟糕,这是正确的。所以我的困惑在于 libtool 脚本最终是如何包含这个虚假的 CXX 配置的。

CC配置没问题。只需使用 --tag=CC 调用 libtool 脚本实际上就足以让我的项目链接得很好。但是,这显然是不正确的;你应该能够执行:

./configure
make

./配置输出

checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for DEPS... yes
checking for udevadm... no
checking build system type... x86_64-apple-darwin12.3.0
checking host system type... x86_64-apple-darwin12.3.0
checking target system type... x86_64-apple-darwin12.3.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld
checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm
checking the name lister (/usr/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-apple-darwin12.3.0 file names to x86_64-apple-darwin12.3.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin12.3.0 file names to toolchain format... func_convert_file_noop
checking for /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin12.3.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking operating system... Darwin/MacOS X
checking for clang++... clang++
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking dependency style of clang++... gcc3
checking whether byte ordering is bigendian... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

设置详细信息

库工具版本: 2.4.2

libtool 修订版: 1.3337

自动配置版本: GNU Autoconf 2.69

clang++ 版本: Apple LLVM 4.2 版(clang-425.0.24)(基于 LLVM 3.2svn)

4

1 回答 1

1

这是由于 AC_PROG_LIBTOOL(因为 LT_INIT 而被弃用)出现在 configure.ac 中的 AC_PROG_CXX([clang++]) 之前。

奇怪的是,LT_INIT/LT_LANG文档实际上显示 LT_INIT 出现在 AC_PROG_CXX 之前,所以我不完全确定为什么这是一个问题。

于 2013-06-06T12:44:52.077 回答