在运行

./configure --prefix=/mingw 

在我之前运行的一个库的MinGW/MSYS系统上

'./configure --prefix=/mingw && make && make install' 

我看到了这条信息:

警告:Vamp插件SDK的一个版本已经安装。如果您安装了新版本而没有先删除旧版本,那么您将会感到担忧和痛苦。(继续)

这让我很担心。“make install”的反义词是什么,即如何在Linux中卸载库?“清洁”能起作用吗,或者还有其他步骤吗?


当前回答

Make可以告诉你它知道什么,它会做什么。 假设你有一个“install”目标,它执行如下命令:

cp <filelist> <destdir>/

在你的通用规则中,添加:

uninstall :; MAKEFLAGS= ${MAKE} -j1 -spinf $(word 1,${MAKEFILE_LIST}) install \
              | awk '/^cp /{dest=$NF; for (i=NF; --i>0;) {print dest"/"$i}}' \
              | xargs rm -f

一个类似的技巧可以做一个通用的使干净。

其他回答

Make可以告诉你它知道什么,它会做什么。 假设你有一个“install”目标,它执行如下命令:

cp <filelist> <destdir>/

在你的通用规则中,添加:

uninstall :; MAKEFLAGS= ${MAKE} -j1 -spinf $(word 1,${MAKEFILE_LIST}) install \
              | awk '/^cp /{dest=$NF; for (i=NF; --i>0;) {print dest"/"$i}}' \
              | xargs rm -f

一个类似的技巧可以做一个通用的使干净。

如果sudo make uninstall不可用:

在基于Debian的系统中,你可以运行sudo checkinstall来生成一个自动安装的.deb文件,而不是(或在*之后)执行make install。然后,您可以使用系统包管理器(例如apt/synaptic/aptitude/dpkg)删除它。Checkinstall还支持创建其他类型的包,例如RPM。

参见http://community.linuxmint.com/tutorial/view/162和一些基本的checkinstall用法和debian checkinstall包。


*:如果你是在安装了make install后阅读这篇文章,你仍然可以按照上面的说明,然后执行dpkg -r $PACKAGE_NAME_YOU_CHOSEN。

序言

下面可能会工作,也可能不会,这都是按原样给出的,你,只有你是负责任的人,以防一些损坏,数据丢失等。但我希望一切顺利!

要撤消make install,我将这样做(我确实这样做了):

想法:检查任何脚本安装和撤销这与简单的bash脚本。

Reconfigure your build dir to install to some custom dir. I usually do this: --prefix=$PWD/install. For CMake, you can go to your build dir, open CMakeCache.txt, and fix CMAKE_INSTALL_PREFIX value. Install project to custom directory (just run make install again). Now we push from assumption, that make install script installs into custom dir just same contents you want to remove from somewhere else (usually /usr/local). So, we need a script. 3.1. Script should compare custom dir, with dir you want clean. I use this:

anti-install.sh

RM_DIR=$1
PRESENT_DIR=$2

echo "Remove files from $RM_DIR, which are present in $PRESENT_DIR"

pushd $RM_DIR

for fn in `find . -iname '*'`; do
#  echo "Checking $PRESENT_DIR/$fn..."
  if test -f "$PRESENT_DIR/$fn"; then
    # First try this, and check whether things go plain
    echo "rm $RM_DIR/$fn"

    # Then uncomment this, (but, check twice it works good to you).
    # rm $RM_DIR/$fn
  fi
done

popd

3.2. 现在只需运行这个脚本(它将进行试运行)

bash anti-install.sh <dir you want to clean> <custom installation dir>

例如,你不想清理/usr/local,而你的自定义安装目录是/user/me/llvm。构建/安装,然后就是

bash anti-install.sh /usr/local /user/me/llvm.build/install

3.3. 仔细检查日志,如果命令对你来说是好的,取消注释rm $RM_DIR/$fn并重新运行它。但是停止!你真的仔细检查过吗?可以再检查一下吗?

指令来源: https://dyatkovskiy.com/2019/11/26/anti-make-install/

好运!

清除源代码/构建树中的任何中间文件或输出文件。然而,它只影响源代码/构建树;它不会触及文件系统的其余部分,因此不会删除先前安装的软件。

如果幸运的话,运行make uninstall就可以了。然而,这取决于图书馆的作者来提供;有些作者提供了卸载目标,有些则没有。

如果你不幸运,你将不得不手动卸载它。运行make -n install可能会很有帮助,因为它将显示软件安装自己所采取的步骤,但实际上不会执行任何操作。然后可以手动反转这些步骤。

我知道很少有包支持“make uninstall”,但更多的包支持“make install DESTDIR=xxx”进行分期安装。

您可以使用它来创建一个包来安装,而不是直接从源代码安装。我没有运气与checkinstall,但fpm工作得很好。

这还可以帮助您删除之前使用make install安装的包。您只需强制在make installed的包上安装您构建的包,然后卸载它。

例如,我最近使用它来处理protobuf-3.3.0。 RHEL7:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t rpm -n protobuf -v 3.3.0 \
 --vendor "You Not RedHat" \
 --license "Google?" \
 --description "protocol buffers" \
 --rpm-dist el7 \
 -m you@youraddress.com \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 --rpm-autoreqprov \
 usr

 sudo rpm -i -f protobuf-3.3.0-1.el7.x86_64.rpm
 sudo rpm -e protobuf-3.3.0      

如果可以的话,你更喜欢yum而不是rpm。

Debian9:

make install DESTDIR=dest
cd dest
fpm -f -s dir -t deb -n protobuf -v 3.3.0 \
-C `pwd` \
--prefix / \
--vendor "You Not Debian" \
--license "$(grep Copyright ../../LICENSE)" \
--description "$(cat README.adoc)" \
--deb-upstream-changelog ../../CHANGES.txt \
 --url "http:/somewhere/where/you/get/the/package/oritssource" \
 usr/local/bin \
 usr/local/lib \
 usr/local/include

 sudo apt install -f *.deb
 sudo apt-get remove protobuf

在你能做到的地方,你更喜欢倾向于dpkg。

我也把答案贴在这里了