configure配置安装详解

由于最近项目需要在HMI层生成二维码,所以去网上找了第三方开源库。可是下载下来里面都是源码,没有动态库或者静态库,所以就需要自己去编译生成。源码库中只有一个configure的可运行得配置脚本,之前用过,没有详细了解,今天去网上查阅资料,以下是整理的一些心得笔记。


首先让我们先来了解一下configure这个文件的作用。


Linux环境下的软件安装,并不是一件容易的事情;如果通过源代码编译后再安装,当然事情就更为复杂一些;现在安装各种软件的教程都非常普遍;但万变不离其中,对基础知识的扎实掌握,安装各种软件的问题就迎刃而解了。Configure脚本配置工具就是基础之一,它是autoconf的工具的基本应用。

configure它是个shell脚本,主要用于编译安装源代码库和软件。 ./configure是源代码安装的第一步,主要的作用是对即将安装的软件进行配置,比如加上 –with、–enable、–without、–disable 等等参数对编译加以控制,检查当前的环境是否满足要安装软件的依赖关系,比如它会检测你是不是有CC或GCC,并不是需要CC或GCC。生成makefile文件,以便你可以用make和make install来编译和安装程序,最后运行make clean删除一些临时文件。
首先我们可以使用 ./configure  --help 就可以查看到所有的配置选项。下面我们对一些重要的常见的进行介绍:
Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/qrencode]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")
  --enable-static[=PKGS]  build static libraries [default=no]
  --enable-dependency-tracking
                          do not reject slow dependency extractors
  --disable-dependency-tracking
                          speeds up one-time build
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-thread-safety  make the library thread-safe. [default=yes]
  --disable-sdltest       Do not try to compile and run a test SDL program
  --disable-rpath         do not hardcode runtime library paths
  --enable-gprof          generate extra code to write profile information
                          suitable for gprof [default=no]
  --enable-gcov           generate extra code to write coverage information
                          suitable for gcov [default=no]
  --enable-mudflap        generate extra code to check memory leaks
                          [default=no]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                          both]
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-sysroot=DIR Search for dependent libraries within DIR
                        (or the compiler's sysroot if not specified).
  --with-tools            build utility tools [default=yes]
  --with-tests            build tests [default=no]
  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)
  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
  --without-libiconv-prefix     don't search for libiconv in includedir and libdir

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  png_CFLAGS  C compiler flags for png, overriding pkg-config
  png_LIBS    linker flags for png, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.


1、--host=HOST
指定软件运行的系统平台.如果没有指定,将会运行`config.guess'来检测.--host 指定的是交叉编译工具链的前缀

2、--build=BUILD
指定软件包安装的系统平台,如当前我们是在intel的pentium机器中编译该系统,那么我们的--build就可能
是i686-pc-linux-gnu,.如果没有指定,默认值将是'--host'选项的值.


3、--target=GARGET
指定软件面向(target to)的系统平台.这主要在程序语言工具如编译器和汇编器上下文中起作用.如果没有指定,默认将使用'--host'选项的值. 

一般而言,我们只要指定 --host 就可以了,--build和--host不同的时候就被配置文件认定为进行交叉编译,否则就是表示本地编译。
从这三个参数的含义来看,说明其处理的目标只有在不同平台下表现为不同的时候才有作用,而这些文件通常都跟目标平台的指令系统直接或间接关:比如可执行文件,对于不同平台下使用的可执行文件的编码可以是完全不同的,因此必须使用 对应能处理该编码的程序才能正确处理,而如果错误的使用则可能导致程序错误或者破坏文件,对于这样要处理不同平台下会 出现不同编码的软件,我们就应当对它指定目标平台,以免另其错误处理;而对于文本文件,对于不同的平台同样的内容表达的 含义都是相同的,因此我们不需要专门针对平台来处理,这样的软件我们就可以不必对它指定需要处理的平台了。
在交叉编译之后,可以用file *** 指令,查看生成的文件的类型,如果不对的话,就可以去查看config.log文件,看看有没有找到相应的编译工具链。


4、-enable-FEATURE[=ARG]
相反的,一些软件包可能提供了一些默认被禁止的特性,可以使用'--enable-FEATURE'来起用它.这里'FEATURE'是特性的名字.一个特性可能会接受一个可选的参数.例如:
$ ./configure --enable-buffers=128

5、`--enable-FEATURE=no'与上面提到的'--disable-FEATURE'是同义的.

--enable-static:生成静态链接库

--enable-shared:生成动态链接库

这两个用来选择生成是静态库还是动态库,但是我配置了无效,具体我也不知道为什么,希望有了解的不吝赐教。

6、'--with-PACKAGE[=ARG]'
在自由软件社区里,有使用已有软件包和库的优秀传统.当用'configure'来配置一个源码树时,可以提供其他已经安装的软件包的信息.例如,倚赖于Tcl和Tk的BLT器件工具包.要配置BLT,可能需要给'configure'提供一些关于我们把Tcl和Tk装的何处的信息: 
$ ./configure --with-tcl=/usr/local --with-tk=/usr/local

'--with-PACKAGE=no'与下面将提到的'--without-PACKAGE'是同义的.

7、'--without-PACKAGE'
有时候你可能不想让你的软件包与系统已有的软件包交互.例如,你可能不想让你的新编译器使用GNU ld.通过使用这个选项可以做到这一点:
$ ./configure --without-gnu-ld


8、也可以配置它们的环境变量,如:

<span style="font-family:SimSun;font-size:14px;">  CC          C compiler command
  CFLAGS      C compiler flags</span>
9、'--prefix=PREFIX'
'--prefix'是最常用的选项.制作出的'Makefile'会查看随此选项传递的参数,当一个包在安装时可以彻底的重新安置他的结构独立部分.
举一个例子,当安装一个包,例如说Emacs,下面的命令将会使Emacs Lisp file被安装到"/opt/gnu/share":
$ ./configure --prefix=/opt/gnu


10、'--bindir=DIR'
指定二进制文件的安装位置.这里的二进制文件定义为可以被用户直接执行的程序.

11、'--sbindir=DIR'
指定超级二进制文件的安装位置.这是一些通常只能由超级用户执行的程序.


12、'--libdir=DIR'
指定库文件的安装位置.

13、'--includedir=DIR'
指定C头文件的安装位置.其他语言如C++的头文件也可以使用此选项.

更为详细的参数的介绍请参考:http://blog.csdn.net/williamwang2013/article/details/8529954

http://blogger.org.cn/blog/more.asp?name=lhwork&id=22496

在此之后,就会自动生成Makefile文件,如果要修改编译器环境等,可以这个时候修改生成的Makefile文件,也可以在。/configure之前,先source下交叉编译需要的环境变量。如果编译的是库文件,就可以把库文件和相应的头文件包含到工程中就可以使用了 。




  • 8
    点赞
  • 47
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
Nagios的安装配置可以按照以下步骤进行: 1. 首先,确保你的系统是Linux或者其他Nagios支持的系统。此外,安装Nagios之前,你需要安装Apache(http服务),因为它提供了一个直观的界面来查看监控信息。你可以在网上找到关于Apache的安装教程。 2. 安装完Apache之后,你需要下载Nagios的安装包并解压。你可以从Nagios官方网站下载最新的稳定版本。 3. 解压后,进入解压后的目录,执行以下命令来编译安装Nagios: ``` ./configure --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode ``` 4. 安装完成后,你需要进行一些配置。首先,你需要编辑Nagios的配置文件,该文件位于`/usr/local/nagios/etc`目录下。你可以使用官方提供的示例配置文件作为起点,该文件已经安装在该目录下。你只需要做一处修改,即将`cfg_dir`的值设置为你自己的配置文件目录。 5. 接下来,你需要创建你自己的配置文件目录,并在该目录下创建你的主机和服务配置文件。你可以参考官方文档或者其他教程来了解如何编写这些配置文件。 6. 配置文件准备好后,你需要检查配置文件是否正确。你可以使用以下命令来检查配置文件: ``` sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg ``` 7. 如果没有错误,你可以启动Nagios服务: ``` sudo service nagios start ``` 8. 现在,你可以通过浏览器访问Nagios的Web界面,输入你的服务器的IP地址或域名,然后登录。你将能够查看监控信息和配置监控项。 这是一个简单的Nagios安装配置的步骤概述。具体的安装配置细节可能会因系统版本和个人需求而有所不同。你可以参考Nagios官方文档和其他教程来获取更详细的信息和指导。 #### 引用[.reference_title] - *1* *3* [nagios安装配置详解1](https://blog.csdn.net/weixin_34138139/article/details/92970215)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [nagios安装配置](https://blog.csdn.net/giveme38/article/details/84524806)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值