惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
博客园 - 司徒正美
Jina AI
Jina AI
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
S
SegmentFault 最新的问题
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
博客园 - Franky
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Commonly-used Building Options Explained
2018-11-07 · via jdhao's digital space

On Linux system, if we do not have root priviledge, we can not use package managers to install a package to its default location (usually under /usr). Besides, the packages installed by the package managers are often too old to have the latest features. Or, even if we have root priviledge, we do not want to mess up with the system-wide packages and just want to experiment with a package locally. On these ocassions, we may want to install the package to a custom location.

The standard procedure to build and install a package from source is something like the following:

./configure
make && make install

By default, the package will be installed under /usr and you must have root priviledge. If you are not familiar with these steps. Read here and here for more discussions on what each step does.

In order to install the package to a custom location and find dependency packages which are not installed on standard locations, we need to set custom options and variables for the configure script. In this post, I will explain the meaning of --prefix, CLFAGS, CXXFLAGS, CPPFLAGS and LDFLAGS.

The meaning of these options and variables#

--prefix#

--prefix is used to tell make where to install the compiled packages. For example, if you use --prefix=$HOME/local, after building the package using make -j, if you do a make install, the binary file will be put in $HOME/local/bin, the library file will be put in $HOME/local/lib or $HOME/local/lib64, the header file will be put in $HOME/local/include and the help file and other resources may be put in $HOME/local/share.

CFLAGS and CXXFLAGS#

CFLAGS and CXXFLAGS are used to set up C and C++ compilers respectively. On most Linux system, the C compiler is usually gcc, while the C++ compilers is usually g++.

CPPFLAGS#

The CPPFLAGS is often mis-understood to set up C++ compiler options. In fact, it is used by C/C++ preprocessors. It tells preprocessor where to find the header files. If you need to set up C++ compiler, you should use CXXFLAGS variable. A valid CPPFLAGS is something like CPPFLAGS="-I$HOME/local/include".

LDFLAGS#

LDFLAGS is used to set up the path of library files. For example, LDFLAGS="-L$HOME/local/lib".

Conclusion#

In this post, I introduced some of the most commonly-used options and flags for the configure script when building packages from source. Understanding these options and flags will help you succeed in building the packages.

Reference#