简体   繁体   English

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

[英]Libtool creates static library only - I need shared objects

I have a couple of C++ classes and I want to compile them into a shared library using autotools and libtool. 我有几个C ++类,我想使用autotools和libtool将它们编译到一个共享库中。 These are my configure.ac and Makefile.am files: 这些是我的configure.ac和Makefile.am文件:

configure.ac: 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: 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 = <sources go here>

somelib_la_LDFLAGS = -version-info $(LIBVER)

library_includedir=$(includedir)/os
library_include_HEADERS = <headers go here>

Libtool only creates static libs, although I call configure --disable-static --enable-shared to explicitly instruct the script to create shared objects. Libtool只创建静态库,尽管我调用configure --disable-static --enable-shared来显式指示脚本创建共享对象。 What is wrong with my files? 我的文件出了什么问题?

--- EDIT --- ---编辑---

The link cmd from libtool: 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'

If libtool somehow believes it's on a platform that doesn't support shared libraries, it simply ignores you and builds static libraries instead. 如果libtool不知何故认为它位于不支持共享库的平台上,它就会忽略你并构建静态库。 I see you're cross-compiling, perhaps libtool doesn't know how to build shared libraries for the target platform. 我看到你是交叉编译的,也许libtool不知道如何为目标平台构建共享库。

You'll want to check your configure output for a line that says something like 您需要检查configure输出以查找类似的行

checking whether to build shared libraries...no 检查是否构建共享库...没有

and then read config.log to find out why. 然后阅读config.log以找出原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM