c – Libtool只创建静态库 – 我需要共享对象

前端之家收集整理的这篇文章主要介绍了c – Libtool只创建静态库 – 我需要共享对象前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有几个C类,我想使用autotools和libtool将它们编译成一个共享库.这些是我的configure.ac和Makefile.am文件

configure.ac:

AC_PREREQ(2.67)
AC_INIT(somelib.so,1.0,someone@somewhere.com)
AC_LANG(C++)
AM_INIT_AUTOMAKE(somelib,1.0)

LT_INIT([disable-static])
AM_DISABLE_STATIC
AM_PROG_LIBTOOL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL

AC_CONFIG_SRCDIR([Logger.cpp])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

AC_SUBST(LIBTOOL_DEPS)
AC_LTDL_DLLIB
AC_PROG_RANLIB

AC_SUBST(LIBTOOL_DEPS)
AC_LTDL_DLLIB

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([cstring unistd.h pthread.h])

# Checks for typedefs,structures,and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([mkdir strdup dup2])
AC_CHECK_LIB(pthread,pthread_create,[],[ echo "ERROR!: libpthread not found!"; exit -1],[])
AC_CHECK_LIB(xml2,htmlReadMemory,[ echo "ERROR!: libxml2 not found!"; exit -1],[])

AC_CONFIG_MACRO_DIR([m4])
AC_OUTPUT(Makefile)

Makefile.am:

AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4
CPPFLAGS = `xml2-config --cflags` -g -fPIC -Wall -O2
AM_LDFLAGS = `xml2-config --libs` -pthread -shared -L$(libdir) -L.libs -lboost_iostreams -lz -lbz2 -L/shared/hudson/arm/lib -I/shared/hudson/arm/include

LIBVER=1:0:0

lib_LTLIBRARIES = somelib.la
somelib_la_SOURCES = 

Libtool只创建静态库,尽管我调用configure –disable-static –enable-shared来显式指示脚本创建共享对象.我的文件出了什么问题?

—编辑—

libtool的链接cmd:

/bin/bash ./libtool --tag=CXX   --mode=link arm-cortex_a8-linux-gnueabi-g++  -g -O2 -version-info 1:0:0  -o somelib.la -rpath /usr/local/lib AutoMutex.lo IniParser.lo Logger.lo Mutex.lo ProcInfo.lo Timer.lo XmlDocContainer.lo XmlNode.lo XmlParser.lo XmlSchemaValidator.lo XmlTree.lo ByteArray.lo IXmlEngine.lo LoggerSetup.lo Process.lo Thread.lo Utils.lo XmlError.lo XmlObjectEngine.lo XmlSchemaEngine.lo XmlSimpleEngine.lo Unziper.lo MUTool.lo  -lxml2 -lpthread -ldl -ldl
libtool: link: arm-cortex_a8-linux-gnueabi-ar cru .libs/somelib.a  AutoMutex.o IniParser.o Logger.o Mutex.o ProcInfo.o Timer.o XmlDocContainer.o XmlNode.o XmlParser.o XmlSchemaValidator.o XmlTree.o ByteArray.o IXmlEngine.o LoggerSetup.o Process.o Thread.o Utils.o XmlError.o XmlObjectEngine.o XmlSchemaEngine.o XmlSimpleEngine.o Unziper.o MUTool.o
libtool: link: arm-cortex_a8-linux-gnueabi-ranlib .libs/somelib.a
libtool: link: ( cd ".libs" && rm -f "somelib.la" && ln -s "../somelib.la" "somelib.la" )
make[1]: Leaving directory `/home/bg/workspace/git/somelib/src'
最佳答案
如果libtool不知何故认为它位于不支持共享库的平台上,它就会忽略你并构建静态库.我看到你是交叉编译的,也许libtool不知道如何为目标平台构建共享库.

您需要检查配置输出以查找类似的行

checking whether to build shared libraries…no

然后阅读config.log以找出原因.

原文链接:https://www.f2er.com/linux/439921.html

猜你在找的Linux相关文章