gpt4 book ai didi

c++ - Libtool 不安装子项目

转载 作者:行者123 更新时间:2023-11-30 04:27:07 26 4
gpt4 key购买 nike

我正在用 C++ 开发一个项目,我希望在其中实现添加插件的功能。编译过程由 Autotools 处理。我设法正确设置了文件结构,主项目和插件都被编译了,但是由于某种原因,在运行 make install 时插件被省略了。单独编译和安装插件时,它工作正常。我是不是遗漏了什么,或者为什么没有从顶级文件夹安装插件?

configure.ac

AC_PREREQ(2.58)
AC_INIT([Net Responsibility],[3.1r323],[contact@netresponsibility.com])
AC_SUBST([LIBTOOL_DEPS])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_SUBDIRS([plugins/defaultReport])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([scripts/m4])
AC_CANONICAL_SYSTEM
AC_LANG([C++])
AC_PREFIX_PROGRAM([make])

AM_INIT_AUTOMAKE([subdir-objects])

LT_PREREQ([2.2])
LT_INIT([shared])


# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL

# Checks for header files.
AC_HEADER_STDC


...

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Makefile.am

# Main library
lib_LTLIBRARIES = libNetResponsibility.la
libNetResponsibility_la_SOURCES = \
@top_srcdir@/src/MainApplication.cpp\
...
libNetResponsibility_la_CPPFLAGS = $(cppFlags)
libNetResponsibility_la_LDFLAGS = -no-undefined $(ldFlags)

# Minimal executable
bin_PROGRAMS = net-responsibility
net_responsibility_SOURCES = @top_srcdir@/src/main.cpp
net_responsibility_LDADD = -lNetResponsibility

dist_pkgdata_DATA = \
$(top_srcdir)/data/txt.xml\
$(top_srcdir)/COPYING

dist_pkgdata_SCRIPTS = $(top_srcdir)/scripts/init.d
dist_noinst_SCRIPTS = $(top_srcdir)/scripts/postinst\
$(top_srcdir)/scripts/prerm

AM_LDFLAGS = -L/usr/local/lib -L/usr/lib
ACLOCAL_AMFLAGS = -I scripts/m4

incDirs = -I$(top_srcdir)/include

ldFlags = -L/usr/local/lib -L/usr/lib

cppFlags = $(incDirs)\
-DPKGDATADIR='$(pkgdatadir)'\
-DPKGLIBDIR='$(pkglibdir)'\
-DDATABASEDIR='$(databasedir)'\
-DPIDDIR='$(piddir)'\
@CPPFLAGS@

AM_CXXFLAGS = $(incDirs) @CXXFLAGS@
AM_CPPFLAGS = $(cppFlags)

EXTRA_DIST = $(top_srcdir)/lib $(top_srcdir)/include

SUBDIRS = . plugins/defaultReport

install: install-am postinst

uninstall: prerm uninstall-am postrm

postinst:
$(top_srcdir)/scripts/postinst $(pkgdatadir) $(initdir)

prerm:
$(top_srcdir)/scripts/prerm $(pkgdatadir) $(initdir)

postrm:
rm -f $(piddir)/net-responsibility.pid
rm -f $(pkgdatadir)/blacklist.xml
rm -f $(pkgdatadir)/config.xml
rm -rf $(pkgdatadir)/reports
rm -f $(databasedir)/net-responsibility.db
rm -f $(initdir)/net-responsibility

.PHONY: prerm postinst postrm

plugins/defaultReport/configure.ac

AC_PREREQ(2.58)
AC_INIT([Net Responsibility Plugin: Default Report],[0.1],[contact@netresponsibility.com])
AC_SUBST([LIBTOOL_DEPS])
AC_SUBST([nrlibdir], ["${libdir}/net-responsibility"])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src/Report.cpp])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_LANG([C++])
AC_PREFIX_PROGRAM([make])

AM_INIT_AUTOMAKE([subdir-objects])

LT_PREREQ([2.2])
LT_INIT([shared])

# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

plugins/defaultReport/Makefile.am

# General settings
ACLOCAL_AMFLAGS = -I m4

ldFlags = -L/usr/local/lib -L/usr/lib

AM_CXXFLAGS = @CXXFLAGS@

# Module specific settings
nrlib_LTLIBRARIES = defaultReport.la
defaultReport_la_SOURCES = \
src/Report.cpp
defaultReport_la_LDFLAGS = -module -no-undefined $(ldFlags)
defaultReport_la_LIBADD = -lNetResponsibility
defaultReport_la_CPPFLAGS = -I../../include @CPPFLAGS@

最佳答案

您需要以不同的方式设置nrlibdir:

plugins/defaultReport/configure.ac

删除这一行:

AC_SUBST([nrlibdir], ["${libdir}/net-responsibility"])

plugins/defaultReport/Makefile.am

nrlib_LTLIBRARIES之前添加这一行:

nrlibdir=$(libdir)/net-responsibility

这应该有助于 automake 正确地完成 make install

编辑:这次我真的试过了。除了上述更改外,删除Makefile.am 中的installuninstall 目标。您应该将 postinstprermpostrm 目标附加到其他一些安装 Hook ,可能类似于:

install-data-hook:
$(top_srcdir)/scripts/postinst $(pkgdatadir) $(initdir)

uninstall-local:
$(top_srcdir)/scripts/prerm $(pkgdatadir) $(initdir)

uninstall-hook:
rm -f $(piddir)/net-responsibility.pid
rm -f $(pkgdatadir)/blacklist.xml
rm -f $(pkgdatadir)/config.xml
rm -rf $(pkgdatadir)/reports
rm -f $(databasedir)/net-responsibility.db
rm -f $(initdir)/net-responsibility

可以替代那些目标。

关于c++ - Libtool 不安装子项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11140153/

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