从源代码构建:configure、make 与 make install
在没有软件包可用时,学习使用 configure、make 和 make install 的经典源代码构建流程,以及它与软件包管理器的关系。
从源代码构建:configure、make 与 make install 是 CoddyKit 上的免费 Linux Command Line Mastery 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Linux Command Line Mastery 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Linux Command Line Mastery 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
When Packages Are Not Enough
Package managers like apt and dnf cover most needs, but sometimes you must build software from source: a newer version, a missing distro package, or custom compile options.
The Three-Step Dance
Most source projects follow the same ritual:
./configurechecks your systemmakecompiles the codemake installcopies files into place
Getting the Source
Source usually arrives as a compressed tarball, which ties back to the archiving skills you already learned.
tar -xzf hello-2.12.tar.gz
cd hello-2.12Installing Build Tools
You need a compiler and make. On Debian/Ubuntu the meta-package build-essential provides them.
sudo apt install build-essentialRunning configure
./configure probes for libraries and generates a Makefile. The --prefix option chooses where it will install.
./configure --prefix=/usr/localCompiling with make
make reads the Makefile and compiles. Use -j to parallelize across CPU cores for speed.
make -j4Installing the Build
make install copies binaries and data into the prefix. Installing to system paths usually needs root.
sudo make installHandling Missing Dependencies
If configure complains about a missing library, install its -dev package, which provides headers needed for compiling.
sudo apt install libssl-devCleaning Up
make clean removes compiled objects so you can rebuild from scratch.
make cleanUninstalling Source Builds
Source installs are not tracked by your package manager. Many projects offer make uninstall, or you can install to /usr/local to keep them separate from packaged software.
sudo make uninstallSource vs Packages
Prefer packages when possible: they handle dependencies and updates. Build from source only when you need control or a version your distro lacks.
Quick Check
Which step actually compiles the program?
Recap
You can build software the classic way:
- Extract the tarball with
tar ./configure --prefix=...sets up the buildmake -jcompiles,sudo make installinstalls- Install -dev packages for missing headers
Reach for source builds only when packages cannot meet your needs.
常见问题解答
「从源代码构建:configure、make 与 make install」课时是免费的吗?
是的 — 「从源代码构建:configure、make 与 make install」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Linux Command Line Mastery 课程的其余内容,请升级到 CoddyKit PRO。 Linux Command Line Mastery 课程共包含 4 节课。
「从源代码构建:configure、make 与 make install」这节课中我会学到什么?
在没有软件包可用时,学习使用 configure、make 和 make install 的经典源代码构建流程,以及它与软件包管理器的关系。 你通过在浏览器中直接运行的动手代码来练习 Linux Command Line Mastery,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Linux Command Line Mastery 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Linux Command Line Mastery 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。
「从源代码构建:configure、make 与 make install」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Linux Command Line Mastery 课中编写并运行代码吗?
能。每节 Linux Command Line Mastery 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 归档与压缩:`tar`、`gzip`、`bzip2`
- 软件包管理(Debian/Ubuntu):`apt`、`dpkg`
- 软件包管理(CentOS/Fedora):`yum`、`dnf`、`rpm`
- 从源代码构建:configure、make 与 make install