走过的弯路:
=============
从官网下载rrdtool-1.4.5.tar.gz源包后,立即解开,然后执行configure,但是会出现一系列的错误,大约说是在第三方库部分,缺这少那的,由于没有仔细看文档,就胡乱的google,胡乱的rpm各种包,依然没有成功。
正确的步骤:
=============
后来,仔细看了看doc目录下的rrdbuild.txt文档,按照文档的提示,一步一步的走,最终成功了。下面的步骤基本来源于这个文档。
大体思路:由于rrdtool利用了很多的第三方工具(N多个),所以,需要这些工具库,但这些工具库,你也需要编译出来才行,所以,编译rrdtool的前提就是把这些库编译出来。这些库成功编译出来以后,再编译rrdtool,基本上一遍就过了。
下面就把步骤贴上来:
0)编译这个的时侯,不象网上说的要安装某某rpm包,个人感觉根本没必要
设置环境:
BUILD_DIR=/rrdbuild INSTALL_DIR=/opt/rrdtool-1.4.5
其中,BUILD_DIR是一个临时目录,之后所有下载的包及相应的操作都在这个目录里进行。INSTALL_DIR是rrdtool最终要安装的目录,这个必须提前设好,不能再更改了。
然后:cd $BUILD_DIR 进入临时目录中,开始把rrdtool所需的要库文件全部编译出来。
下面是整个依存库的编译过程,这部分来源于rrdtoolbuild.txt。我在编译的时侯,没有设置MAKE变量,直接手工make/make install的。
Building pkgconfig
As mentioned above, without pkgconfig the whole build process will be lots of pain and suffering, so make sure you have a copy on your system. If it is not available natively, here is how to compile it.
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz gunzip -c pkg-config-0.23.tar.gz | tar xf - cd pkg-config-0.23 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" $MAKE $MAKE install
After installing pkgconfig in a custom directory, setting up the corresponding environment variable will be helpful.
export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config
Building zlib
Chances are very high that you already have that on your system ...
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz gunzip -c zlib-1.2.3.tar.gz | tar xf - cd zlib-1.2.3 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" --shared $MAKE $MAKE install
Building libpng
Libpng itself requires zlib to build, so we need to help a bit. If you already have a copy of zlib on your system (which is very likely) you can drop the settings of LDFLAGS and CPPFLAGS. Note that the backslash (\) at the end of line 4 means that line 4 and line 5 are on one line.
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.18.tar.gz gunzip -c libpng-1.2.18.tar.gz | tar xf - cd libpng-1.2.10 env CFLAGS="-O3 -fPIC" ./configure --prefix=$INSTALL_DIR $MAKE $MAKE install
Building freetype
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz gunzip -c freetype-2.3.5.tar.gz | tar xf - cd freetype-2.3.5 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" $MAKE $MAKE install
If you run into problems building freetype on Solaris, you may want to try to add the following at the start the configure line:
env EGREP=egrep
Building LibXML2
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/libxml2-2.6.32.tar.gz gunzip -c libxml2-2.6.32.tar.gz | tar xf - cd libxml2-2.6.32 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" $MAKE $MAKE install
Building fontconfig
Note that fontconfig has a run time configuration file in INSTALL_DIR/etc you may want to adjust that so that fontconfig finds the fonts on your system. Run the fc-cache program to build the fontconfig cache after changing the config file.
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz gunzip -c fontconfig-2.4.2.tar.gz | tar xf - cd fontconfig-2.4.2 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" --with-freetype-config=$INSTALL_DIR/bin/freetype-config $MAKE $MAKE install
Building Pixman
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz gunzip -c pixman-0.10.0.tar.gz | tar xf - cd pixman-0.10.0 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" $MAKE $MAKE install
Building Cairo
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz gunzip -c cairo-1.6.4.tar.gz | tar xf - cd cairo-1.6.4 ./configure --prefix=$INSTALL_DIR \ --enable-xlib=no \ --enable-xlib-render=no \ --enable-win32=no \ CFLAGS="-O3 -fPIC" $MAKE $MAKE install
When building on Solaris you may want todo
./configure --prefix=$INSTALL_DIR \ --enable-xlib=no \ --enable-xlib-render=no \ --enable-win32=no \ CFLAGS="-O3 -fPIC -D_POSIX_PTHREAD_SEMANTICS"
Building Glib
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.15.4.tar.gz gunzip -c glib-2.15.4.tar.gz | tar xf - cd glib-2.15.4 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" $MAKE $MAKE install
Building Pango
cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2 bunzip2 -c pango-1.21.1.tar.bz2 | tar xf - cd pango-1.21.1 ./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC" --without-x $MAKE $MAKE install
以上执行完成后,就完成了对整个rrdtool依存库的建立,各种库都有了,就可以对rrdtool本身进行编译了。
Building rrdtool
cd $BUILD_DIR/rrdtool-1.4.5 ./configure --prefix=$INSTALL_DIR --disable-tcl --disable-python $MAKE clean $MAKE $MAKE install
至此,编译全部完成,rrdtool被放在/opt/rrdtool-1.4.5下面。将这个目录tar成一个包,注意必须要全路径tar, 然后COPY到其它机器上TAR开就可以在其它机器上用了。
一定注意:绝对目录一定不能变,例如:你编译的时侯是安装在/opt/rrdtool-1.4.5目录下,完成后,你改到/var/usr/rrdtoo-1.4.5下,这是不行的,运行的时侯会告诉你找不到库文件。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话