Autoconf未生成共享对象问题排查求助
动态编译Autoconf项目时共享库构建异常问题
静态编译可正常完成,但动态编译时出现异常:生成的libfoo.so是指向libfoo.so.0.0.0的符号链接,然而libfoo.so.0.0.0并未实际构建。静态库可正常生成,无论是静态还是动态编译,make都能正常执行(但输出内容过多难以排查),执行make install时因找不到libfoo.so.0.0.0而失败。
从无效符号链接和make install失败可以看出,Autoconf似乎认为应当已构建共享对象。
顶层configure.ac内容
AC_INIT(foo, 0.96, somebody@email.com) AC_CONFIG_SRCDIR([README]) SHARED_VERSION_INFO="0:0:0" # CURRENT:REVISION:AGE AM_INIT_AUTOMAKE LT_INIT AM_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_MAINTAINER_MODE AC_SUBST(SHARED_VERSION_INFO) AC_DISABLE_SHARED dnl shared libs by default cause too much trouble AC_PROG_CXX AC_PROG_F77 # and other macros to process plenty of --with-this and --with-that options
libfoo目录下的Makefile.am内容
lib_LTLIBRARIES = libfoo.la pkginclude_HEADERS = libfoo.h \ many.h \ other.h \ ones.h libfoo_la_SOURCES = \ this.cc \ and.cc \ that.cc libfoo_la_LIBADD = \ ../libsomething/libsomething.la \ ../libsome/libsome.la \ ../libthing/libthing.la \ ../libelse/libelse.la libfoo_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ # these are same as in LIBADD and more AM_CPPFLAGS = -I$(top_srcdir)/libs/libsomething \ -I$(top_srcdir)/libs/libsome \ -I$(top_srcdir)/libs/libthing \ -I$(top_srcdir)/libs/libelse \ -I$(top_srcdir)/libs/liband \ -I$(top_srcdir)/libs/libmore \ # and this is the entire Makefile.am
疑问
- 可采取哪些步骤调试该问题?
- configure.ac中是否可能存在某些选项,使
libfoo.so.0.0.0的构建带有make的-前缀(或类似--ignore-errors的选项)?考虑到make能完成但make install失败,这种情况似乎合理,若存在此类选项,移除它可让make失败从而帮助定位根因。 - 还有其他建议吗?
补充说明
- 项目代码以C++为主,夹杂少量C代码,使用GNU make。
- 无自定义脚本,完整构建流程仅为
autoconf、configure、make,且使用libtool。 - 排查构建过程的stdout和stderr未发现任何错误,仅存在一些“无关紧要”的警告(如
-Wunused-variable、-Wmaybe-uninitialized、-Wtautological-compare等)。 - stdout和stderr中仅在以下几行提及
libfoo.so:
libtool: link: (stuff for the static linking) libtool: link: (cd ".libs" && rm -f "libfoo.so.0" && ln -s "libfoo.so.0.0.0" "libfoo.so.0") libtool: link: (cd ".libs" && rm -f "libfoo.so" && ln -s "libfoo.so.0.0.0" "libfoo.so") libtool: link: (other stuff for the static linking)
- libtool中未提及任何libfoo相关内容(无论扩展名),对libtool并不熟悉。
- 查找
keep-going相关内容:find . -name Makefile | xargs grep keep-going未找到任何结果。
线索
- 在
.libs目录中,静态链接后.o文件会被删除,而动态链接后.o文件会被保留。 - 近千次编译器调用中仅出现13次
-fPIC参数。
困惑点:Autotool/libtool一方面认为正在构建共享对象(因为生成了这些符号链接),另一方面却没有实际构建的痕迹(除了上述小线索)。
内容的提问来源于stack exchange,提问作者Davide
相关产品推荐
相关产品推荐

