“make install”的反义词是什么,即如何在 Linux 中卸载库?

发布于 2024-08-04 14:24:04 字数 399 浏览 5 评论 0原文

运行时,

./configure --prefix=/mingw 

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

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

我遇到了以下消息:

警告:已安装 Vamp 插件 SDK 版本。如果您安装新版本而没有先删除旧版本,那么您会感到担忧和悲伤。 (继续)

这让我很担心。 'make install' 的反义词是什么,即如何在 Linux 中卸载库? “make clean”可以完成这项工作,还是还涉及其他步骤?

While running

./configure --prefix=/mingw 

on a MinGW/MSYS system for a library I had previously run

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

I came across this message:

WARNING: A version of the Vamp plugin SDK is already installed. Expect worries and sorrows if you install a new version without removing the old one first. (Continuing)

This had me worried. What's the opposite of 'make install', i.e. how is a library uninstalled in Linux? Will 'make clean' do the job, or are there other steps involved?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

以为你会在 2024-08-11 14:24:04

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

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

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

make clean removes any intermediate or output files from your source / build tree. However, it only affects the source / build tree; it does not touch the rest of the filesystem and so will not remove previously installed software.

If you're lucky, running make uninstall will work. It's up to the library's authors to provide that, however; some authors provide an uninstall target, others don't.

If you're not lucky, you'll have to manually uninstall it. Running make -n install can be helpful, since it will show the steps that the software would take to install itself but won't actually do anything. You can then manually reverse those steps.

谜泪 2024-08-11 14:24:04

如果 sudo make uninstall 不可用:

在基于 Debian 的系统中,您可以(在构建目录中)而不是(或在*之后)执行 make install

sudo apt install checkinstall
sudo checkinstall

:自动安装的 code>.deb 文件。然后,您可以使用系统包管理器(例如apt/synaptic/aptitude/dpkg)将其删除。 Checkinstall还支持创建其他类型的包,例如RPM。

另请参阅 http://community.linuxmint.com/tutorial/view/162 和 < a href="https://help.ubuntu.com/community/CheckInstall" rel="noreferrer">一些基本的 checkinstall 用法 和 debian checkinstall 包


*:如果您在使用 make install 安装后阅读本文,您仍然可以按照上述说明进行操作,然后执行 dpkg -r $PACKAGE_NAME_YOU_CHOSEN

If sudo make uninstall is unavailable:

In a Debian based system, instead of (or after*) doing make install you can (in the build directory):

sudo apt install checkinstall
sudo checkinstall

To make a .deb file that gets automatically installed. You can then remove it using the system package manager (e.g. apt/synaptic/aptitude/dpkg). Checkinstall also supports creating other types of package, e.g. RPM.

See also http://community.linuxmint.com/tutorial/view/162 and some basic checkinstall usage and debian checkinstall package.


*: If you're reading this after having installed with make install you can still follow the above instructions and do a dpkg -r $PACKAGE_NAME_YOU_CHOSEN afterwards.

捎一片雪花 2024-08-11 14:24:04

如果您有一个 manifest 文件,其中列出了使用 make install 安装的所有文件,您可以运行我从另一个答案中获得的此命令:

cat install_manifest.txt | xargs echo rm | sh

如果您有 sudo make install 您需要在卸载中添加 sudo:

cat install_manifest.txt | xargs echo sudo rm | sh

If you have a manifest file which lists all the files that were installed with make install you can run this command which I have from another answer:

cat install_manifest.txt | xargs echo rm | sh

If you have sudo make install you will need to add a sudo to your uninstall:

cat install_manifest.txt | xargs echo sudo rm | sh
潦草背影 2024-08-11 14:24:04

如何在“make install”后卸载

方法 #1(make uninstall)

第 1 步:如果您以任何方式删除/更改了构建目录,则只需执行此步骤:下载并 make/使用与之前完全相同相同的过程进行安装。

第2步:尝试进行卸载。

cd $SOURCE_DIR 
sudo make uninstall

如果成功,您就完成了。如果您很疑虑,您也可以尝试“方法 #3”的步骤,以确保 make uninstall 没有丢失任何文件。

方法#2(checkinstall - 仅适用于基于 debian 的系统)

过程概述

在基于 debian 的系统(例如 Ubuntu)中,您可以使用以下命令非常轻松地创建 .deb 包名为 checkinstall 的工具。然后安装 .deb 软件包(这将使您的 debian 系统意识到您的软件包的所有部分确实已安装),最后卸载它以让您的软件包管理器正确清理您的系统。

一步一步

sudo apt-get -y install checkinstall
cd $SOURCE_DIR 
sudo checkinstall

此时,checkinstall 将提示输入包名称。输入一些描述性的内容并记下它,因为您很快就会用到它。它还会提示您输入更多可以忽略的数据。如果它抱怨版本不可接受,只需输入一些合理的内容,例如 1.0。完成后,您可以安装并最终卸载:

sudo dpkg -i $PACKAGE_NAME_YOU_ENTERED 
sudo dpkg -r $PACKAGE_NAME_YOU_ENTERED

方法 #3 (install_manifest.txt)

如果文件 install_manifest.txt 存在于您的源目录中,它应该包含安装创建的每个文件的文件名。

因此,首先检查文件列表及其修改时间:

cd $SOURCE_DIR 
sudo xargs -I{} stat -c "%z %n" "{}" < install_manifest.txt

您应该得到零错误,并且列出的文件的修改时间应该安装时间或之后。如果一切正常,您可以一次性删除它们:

cd $SOURCE_DIR 
mkdir deleted-by-uninstall
sudo xargs -I{} mv -t deleted-by-uninstall "{}" < install_manifest.txt

但是,用户 Merlyn Morgan-Graham 有一个关于此方法的严重通知,您应该牢记在心(逐字复制到此处):“请注意可能已被删除的文件由其他软件包安装。简单地删除这些文件[...]可能会破坏其他软件包。”。这就是我们创建 deleted-by-uninstall 目录并将文件移动到那里而不是删除它们的原因。


这篇文章99%的内容都存在于其他答案中。我只是在(希望)易于遵循的操作方法中收集了所有有用的内容,并尝试特别注意重要的细节(例如引用 xarg 参数和保留已删除文件的备份)。

How to uninstall after "make install"

Method #1 (make uninstall)

Step 1: You only need to follow this step if you've deleted/altered the build directory in any way: Download and make/make install using the exact same procedure as you did before.

Step 2: try make uninstall.

cd $SOURCE_DIR 
sudo make uninstall

If this succeeds you are done. If you're paranoid you may also try the steps of "Method #3" to make sure make uninstall didn't miss any files.

Method #2 (checkinstall -- only for debian based systems)

Overview of the process

In debian based systems (e.g. Ubuntu) you can create a .deb package very easily by using a tool named checkinstall. You then install the .deb package (this will make your debian system realize that the all parts of your package have been indeed installed) and finally uninstall it to let your package manager properly cleanup your system.

Step by step

sudo apt-get -y install checkinstall
cd $SOURCE_DIR 
sudo checkinstall

At this point checkinstall will prompt for a package name. Enter something a bit descriptive and note it because you'll use it in a minute. It will also prompt for a few more data that you can ignore. If it complains about the version not been acceptable just enter something reasonable like 1.0. When it completes you can install and finally uninstall:

sudo dpkg -i $PACKAGE_NAME_YOU_ENTERED 
sudo dpkg -r $PACKAGE_NAME_YOU_ENTERED

Method #3 (install_manifest.txt)

If a file install_manifest.txt exists in your source dir it should contain the filenames of every single file that the installation created.

So first check the list of files and their mod-time:

cd $SOURCE_DIR 
sudo xargs -I{} stat -c "%z %n" "{}" < install_manifest.txt

You should get zero errors and the mod-times of the listed files should be on or after the installation time. If all is OK you can delete them in one go:

cd $SOURCE_DIR 
mkdir deleted-by-uninstall
sudo xargs -I{} mv -t deleted-by-uninstall "{}" < install_manifest.txt

User Merlyn Morgan-Graham however has a serious notice regarding this method that you should keep in mind (copied here verbatim): "Watch out for files that might also have been installed by other packages. Simply deleting these files [...] could break the other packages.". That's the reason that we've created the deleted-by-uninstall dir and moved files there instead of deleting them.


99% of this post existed in other answers. I just collected everything useful in a (hopefully) easy to follow how-to and tried to give extra attention to important details (like quoting xarg arguments and keeping backups of deleted files).

牵你手 2024-08-11 14:24:04

根据相关程序的 makefile/configure script/autofoo 魔力的好坏,以下内容可能会解决您的问题:

make uninstall

问题是您应该在已安装版本的源代码树上执行此操作,并使用完全相同的内容您用于安装的配置。

Depending on how well the makefile/configure script/autofoo magic of the program in question is the following might solve your problem:

make uninstall

The problem is that you should execute this on the source tree of the version you've got installed and with exactly the same configuration that you used for installing.

善良天后 2024-08-11 14:24:04

make clean 通常只清理包含源代码本身的目录中的构建文件,很少触及任何已安装的软件。

Makefile 通常不包含卸载目标——您通常必须自己执行此操作,方法是从安装目录中删除文件。例如,如果您构建了一个程序并将其安装(使用 make install)到 /usr/local 中,则您需要查看 /usr/local /bin/usr/local/libexec/usr/local/share/man等,并删除不需要的文件。有时 Makefile 包含卸载目标,但并非总是如此。

当然,通常在 Linux 系统上,您使用包管理器安装软件,它能够“自动”卸载软件。

make clean generally only cleans built files in the directory containing the source code itself, and rarely touches any installed software.

Makefiles generally don't contain a target for uninstallation -- you usually have to do that yourself, by removing the files from the directory into which they were installed. For example, if you built a program and installed it (using make install) into /usr/local, you'd want to look through /usr/local/bin, /usr/local/libexec, /usr/local/share/man, etc., and remove the unwanted files. Sometimes a Makefile includes an uninstall target, but not always.

Of course, typically on a Linux system you install software using a package manager, which is capable of uninstalling software "automagically".

夏末染殇 2024-08-11 14:24:04

“stow”实用程序旨在解决此问题: http://www.gnu.org/software/收起/

The "stow" utility was designed to solve this problem: http://www.gnu.org/software/stow/

揽月 2024-08-11 14:24:04

方法 1

从源文件夹:

#make uninstall

方法 2

如果没有卸载过程:

  1. 打开 install_manifest.txt(由#make install)

  2. 删除列出的所有目录/文件

  3. 删除您错过的任何剩余文件:

    <代码>#xargs rm < install_manifest.txt

  4. 删除所有隐藏的目录/文件:

    $rm -rf ~/.packagename

删除源文件夹。

方法 3

如果以上选项均不起作用,请查看安装过程:

#make -n install

并逆向安装过程:

#rm -rf alldirectories/创建的文件

示例

例如,这是如何从源卸载nodejs、npm和nvm:

如何我是否完全卸载 Node.js,然后从头开始重新安装 (Mac OS X)

您可以使用上述任何方法来完成。

Method 1

From the source folder:

#make uninstall

Method 2

If there is no uninstall procedure:

  1. open install_manifest.txt (created by #make install)

  2. remove all the directories/files listed

  3. remove any remaining files you missed:

    #xargs rm < install_manifest.txt

  4. remove any hidden directories/files:

    $rm -rf ~/.packagename

Remove the source folder.

Method 3

If none of the above options work, view the install procedure:

#make -n install

and reverse the install procedure:

#rm -rf all directories/files created

Example

For example, this is how to uninstall nodejs, npm, and nvm from source:

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

which you can do using any of the above methods.

归属感 2024-08-11 14:24:04

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

make uninstall

从源目录可能会起作用。否则,可能需要手动撤消 make install 所做的一切。

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

There is no standard unfortunately, this is one of the perils of installing from source. Some Makefiles will include an "uninstall", so

make uninstall

from the source directory may work. Otherwise, it may be a matter of manually undoing whatever the make install did.

make clean usually just cleans up the source directory - removing generated/compiled files and the like, probably not what you're after.

相思故 2024-08-11 14:24:04

Make

Make 是用于安装从源代码编译的程序的程序。它不是 Linux 包管理器,因此它不会跟踪它安装的文件。这使得以后卸载这些文件变得困难。

Make Install 命令将构建的程序和包复制到库目录和 makefile 中的指定位置。这些地点
可能会根据配置脚本执行的检查而有所不同。

CheckInstall

CheckInstall 是用于安装或卸载从源代码编译的程序的程序。它监视并复制使用 make 程序安装的文件。它还使用 Linux 包管理器安装文件,这样就可以像任何常规包一样卸载它。

CheckInstall 命令用于调用Make Install 命令。它监视已安装的文件并从中创建二进制包。它还使用 Linux 包管理器安装二进制包。

将“source_location.deb”和“名称”替换为您的信息 屏幕截图< /a>.

在源码包目录下执行以下命令:

  1. 安装CheckInstall sudo apt-get install checkinstall
  2. 运行Configure脚本 sudo ./configure
  3. 运行Make命令sudo make< /code>
  4. 运行 CheckInstall sudo checkinstall
  5. 重新安装软件包 sudo dpkg --install --force-overwrite source_location.deb
  6. 删除软件包 sudo apt remove name >

这是一篇文章 我写的文章涵盖了整个过程并进行了解释。

Make

Make is the program that’s used to install the program that’s compiled from the source code. It’s not the Linux package manager so it doesn’t keep track of the files it installs. This makes it difficult to uninstall the files afterward.

The Make Install command copies the built program and packages into the library directory and specified locations from the makefile. These locations
can vary based on the examination that’s performed by the configure script.

CheckInstall

CheckInstall is the program that’s used to install or uninstall programs that are compiled from the source code. It monitors and copies the files that are installed using the make program. It also installs the files using the Linux package manager which allows it to be uninstalled like any regular package.

The CheckInstall command is used to call the Make Install command. It monitors the files that are installed and creates a binary package from them. It also installs the binary package with the Linux package manager.

Replace "source_location.deb" and "name" with your information from the Screenshot.

Execute the following commands in the source package directory:

  1. Install CheckInstall sudo apt-get install checkinstall
  2. Run the Configure script sudo ./configure
  3. Run the Make command sudo make
  4. Run CheckInstall sudo checkinstall
  5. Reinstall the package sudo dpkg --install --force-overwrite source_location.deb
  6. Remove the package sudo apt remove name

Here's an article article I wrote that covers the whole process with explanations.

梦断已成空 2024-08-11 14:24:04

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

您可以使用它来创建一个要安装的软件包,而不是直接从源安装。我没有运气checkinstall 但 fpm 效果很好,

这也可以帮助您删除以前使用 make 安装的软件包 。安装。你只需强制安装你构建的包,然后卸载它。

例如,我最近使用它来处理 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 [email protected] \
 --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

尽可能选择 apt 和 dpkg。

我还发布了答案这里

I know of few packages that support "make uninstall" but many more that support make install DESTDIR=xxx" for staged installs.

You can use this to create a package which you install instead of installing directly from the source. I had no luck with checkinstall but fpm works very well.

This can also help you remove a package previously installed using make install. You simply force install your built package over the make installed one and then uninstall it.

For example, I used this recently to deal with protobuf-3.3.0.
On 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 [email protected] \
 --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      

Prefer yum to rpm if you can.

On 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

Prefer apt to dpkg where you can.

I've also posted answer this here

淡淡の花香 2024-08-11 14:24:04

Make 可以告诉您它知道什么以及它将做什么。
假设您有一个“安装”目标,它执行如下命令:

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 clean

Make can tell you what it knows and what it will do.
Suppose you have an "install" target, which executes commands like:

cp <filelist> <destdir>/

In your generic rules, add:

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

A similar trick can do a generic make clean.

小…红帽 2024-08-11 14:24:04

序言

下面的内容可能有效,也可能无效,这一切都是按原样提供的,如果出现某些损坏、数据丢失等情况,您是唯一的负责人。但我希望事情进展顺利!

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

想法:检查安装的任何脚本并使用简单的 bash 脚本撤消此操作。< /em>

  1. 重新配置您的构建目录以安装到某个自定义目录。我通常这样做:--prefix=$PWD/install。对于 CMake,您可以转到构建目录,打开 CMakeCache.txt,然后修复 CMAKE_INSTALL_PREFIX 值。
  2. 将项目安装到自定义目录(只需再次运行make install)。
  3. 现在我们从假设出发,make install 脚本安装到自定义目录中的内容与您想要从其他地方(通常是 /usr/local)删除的内容相同。所以,我们需要一个脚本。
    3.1.脚本应该将自定义目录与您想要清理的目录进行比较。我使用这个:

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.build/install,那么它将是

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/

祝你好运!

Preamble

below may work or may not, this is all given as-is, you and only you are responsible person in case of some damage, data loss and so on. But I hope things go smooth!

To undo make install I would do (and I did) this:

Idea: check whatever script installs and undo this with simple bash script.

  1. 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.
  2. Install project to custom directory (just run make install again).
  3. 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. Now just run this script (it will go dry-run)

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

E.g. You wan't to clean /usr/local, and your custom installation dir is /user/me/llvm.build/install, then it would be

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

3.3. Check log carefully, if commands are good to you, uncomment rm $RM_DIR/$fn and run it again. But stop! Did you really check carefully? May be check again?

Source to instructions:
https://dyatkovskiy.com/2019/11/26/anti-make-install/

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文