在运行

./configure --prefix=/mingw 

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

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

我看到了这条信息:

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

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


当前回答

序言

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

要撤消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/

好运!

其他回答

不幸的是,没有标准,这是从源代码安装的危险之一。一些makefile文件将包含“卸载”,因此

make uninstall

从源目录可以工作。否则,可能需要手动撤销make install所做的一切。

Make clean通常只是清理源目录-删除生成/编译的文件之类的,可能不是你想要的。

如果你有一个清单文件,其中列出了所有安装make install的文件,你可以运行这个命令,这是我从另一个答案:

cat install_manifest.txt | xargs echo rm | sh

如果你有sudo make install,你需要添加一个sudo到你的卸载:

cat install_manifest.txt | xargs echo sudo rm | sh

我知道很少有包支持“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。

我也把答案贴在这里了

“stow”实用程序就是用来解决这个问题的:http://www.gnu.org/software/stow/

如果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。