gpt4 book ai didi

c++ - 移除 stdc++ 库依赖

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:10:04 24 4
gpt4 key购买 nike

我有一个用 C++ 编写的库,但没有使用 stdc++ 库,因为它在某些平台上不可用。

但是,我的 libsmartrest.la 中仍然有 stdc++ 库依赖项,这使得依赖于该库的所有库都无法链接。

这是我的 configure.ac 和 Makefile.am:

# Process this file with autoreconf to produce a configure script.
# See http://www.openismus.com/documents/linux/building_libraries/building_libraries for introduction.

AC_INIT([Cumulocity SmartREST C++ Library], [1.0.0], [support@cumulocity.com], [libsmartrest], [https://bitbucket.org/m2m/cumulocity-clients-c/])

# Must come before AM_INIT_AUTOMAKE.
AC_CONFIG_MACRO_DIR([m4])

# These are automake arguments, not compiler arguments.
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])

AC_PROG_CXX
AM_PROG_AR([act-if-fail])
LT_INIT

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

# Checks for library functions.
AC_CHECK_FUNCS([strerror])
AC_FUNC_MALLOC

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])

AC_OUTPUT

dnl Print configuration summary

cat <<EOF
=====================

$PACKAGE_NAME (version $PACKAGE_VERSION) is now configured.
You can now build, test and install $PACKAGE_NAME using the Makefile, by calling

\$ make
\$ make check # Optional
\$ make install

EOF

生成文件.am:

ACLOCAL_AMFLAGS = -I m4

lib_LTLIBRARIES = libsmartrest.la

libsmartrest_la_SOURCES = \
src/Aggregator.cpp\
src/CharValue.cpp\
src/FloatValue.cpp\
src/IntegerValue.cpp\
src/NullValue.cpp\
src/Parser.cpp\
src/ParsedRecord.cpp\
src/ParsedValue.cpp\
src/SmartRest.cpp\
src/Record.cpp\
src/ComposedRecord.cpp\
src/StaticData.cpp
libsmartrest_la_CXXFLAGS = -fPIC -Wall -Wextra -Wno-deprecated
libsmartrest_la_LDFLAGS = -version-info 1:0:0

libsmartrest_hdir = $(includedir)/smartrest
libsmartrest_h_HEADERS = \
src/AbstractClient.h\
src/AbstractDataSink.h\
src/AbstractDataSource.h\
src/Aggregator.h\
src/CharValue.h\
src/DataGenerator.h\
src/FloatValue.h\
src/IntegerValue.h\
src/NullValue.h\
src/Parser.h\
src/ParsedRecord.h\
src/ParsedValue.h\
src/SmartRest.h\
src/Record.h\
src/ComposedRecord.h\
src/StaticData.h\
src/Value.h

EXTRA_DIST = README \
LICENSE

TESTS = $(check_PROGRAMS)
check_PROGRAMS = values parser client
values_SOURCES = \
test/values/mainvalues.cpp\
test/mock/BufferedDataSink.cpp\
test/values/CharValueTest.cpp\
test/values/ParsedValueTest.cpp\
test/values/AggregatorTest.cpp\
test/values/IntegerValueTest.cpp\
test/values/FloatValueTest.cpp\
test/values/ComposedRecordTest.cpp
values_CXXFLAGS = -Wall -Wextra -I$(srcdir)/src
values_LDADD = -lsmartrest
parser_SOURCES = \
test/parser/mainparser.cpp\
test/mock/BufferedDataSource.cpp\
test/parser/ParserTest.cpp
parser_CXXFLAGS = -Wall -Wextra -I$(srcdir)/src
parser_LDADD = -lsmartrest
client_SOURCES = \
test/client/mainclient.cpp\
test/client/SmartRestTest.cpp\
test/mock/BufferedDataSource.cpp\
test/mock/BufferedDataSink.cpp\
test/mock/MockClient.cpp\
test/mock/MockSmartRest.cpp
client_CXXFLAGS = -Wall -Wextra -I$(srcdir)/src
client_LDADD = -lsmartrest

在我的桌面系统上编译很顺利。但是,我在我的 .la 文件中得到了这个:

dependency_libs=' -L/home/ec2-user/SDK_Bovine_ntc_6200/libstage/lib /home/mattf/src/buildbot/sandbox/slave/release_ntc_6200/build/Bovine_src/staging_sdk/SDK_Bovine_ntc_6200/compiler/arm-cdcs-linux-gnueabi/lib/libstdc++.la'

谁能告诉我如何去除这种依赖性?

最佳答案

您可能正在使用基于 RTTI 的 C++ 功能,例如异常或 typeof/dynmaic_cast。您可以尝试使用 -fno-rtti -fno-exceptions 进行构建。那应该删除依赖项或显示您实际拥有它的位置。

如果这没有帮助并且您使用的是 GCC 4.5 或更新版本,请尝试使用 -static-libstdc++ 进行编译。

关于c++ - 移除 stdc++ 库依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24432844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com