展開したファイルをコンパイル (configure, make) 出来ない

LINEで送る
Pocket

前回記事 圧縮されたアーカイブファイルが展開出来ない!(ソースコードを自分でコンパイルした時のトラブルシューティング)

configure を実行すると何らかのエラーが出力され途中で止まってしまいコンパイル出来ない。コンパイル出来ないからお目当てのソフトウェアがインストール出来なかったなんて経験みなさんあると思います。

# tar xvfj httpd-2.4.29.tar.bz2
# cd httpd-2.4.29
# ./configure
# ./configure 
checking for chosen layout... Apache<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc                                   <- gcc が無い。
checking whether the C compiler works... no               <- cc が無い。
configure: error: in `/root/httpd-2.4.29':
configure: error: C compiler cannot create executables   <- C コンパイラーが見つかりませんでした。

configure は、そのシステムに、コンパイルを行うためのコマンド、システムコール、ライブラリなどが揃っているかどうかをチェックしています。ログをよく見ると「checking for gcc… no, checking for cc… no」、最後に C コンパイラーが見つかりませんでしたと出力されています。

ということで gcc パッケージをダウンロードして rpm コマンドでインストールしてみますが、依存関係のエラーでパッケージがインストール出来ません。

# wget ftp.riken.jp:/pub/Linux/centos/7/updates/x86_64/Packages/gcc-4.8.5-16.el7_4.1.x86_64.rpm
# rpm -ivh gcc-4.8.5-16.el7_4.1.x86_64.rpm 
エラー: 依存性の欠如:
	cpp = 4.8.5-16.el7_4.1 は gcc-4.8.5-16.el7_4.1.x86_64 に必要とされています
	glibc-devel &amp;gt;= 2.2.90-12 は gcc-4.8.5-16.el7_4.1.x86_64 に必要とされています
	libgcc &amp;gt;= 4.8.5-16.el7_4.1 は gcc-4.8.5-16.el7_4.1.x86_64 に必要とされています
	libgomp = 4.8.5-16.el7_4.1 は gcc-4.8.5-16.el7_4.1.x86_64 に必要とされています
	libmpc.so.3()(64bit) は gcc-4.8.5-16.el7_4.1.x86_64 に必要とされています

ということでパッケージ管理ツール yum を使った方法で C コンパイラーの gcc をインストールしてみましょう。

# yum install gcc
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * nux-dextop: mirror.li.nux.ro
 * updates: ftp.riken.jp
依存性の解決をしています
--&amp;gt; トランザクションの確認を実行しています。
---&amp;gt; パッケージ gcc.x86_64 0:4.8.5-16.el7_4.1 を インストール
--&amp;gt; 依存性の処理をしています: libgomp = 4.8.5-16.el7_4.1 のパッケージ: gcc-4.8.5-16.el7_4.1.x86_64
--&amp;gt; 依存性の処理をしています: cpp = 4.8.5-16.el7_4.1 のパッケージ: gcc-4.8.5-16.el7_4.1.x86_64
--&amp;gt; 依存性の処理をしています: libgcc &amp;gt;= 4.8.5-16.el7_4.1 のパッケージ: gcc-4.8.5-16.el7_4.1.x86_64
--&amp;gt; 依存性の処理をしています: glibc-devel &amp;gt;= 2.2.90-12 のパッケージ: gcc-4.8.5-16.el7_4.1.x86_64
--&amp;gt; 依存性の処理をしています: libmpc.so.3()(64bit) のパッケージ: gcc-4.8.5-16.el7_4.1.x86_64
--&amp;gt; トランザクションの確認を実行しています。
---&amp;gt; パッケージ cpp.x86_64 0:4.8.5-16.el7_4.1 を インストール
---&amp;gt; パッケージ glibc-devel.x86_64 0:2.17-196.el7_4.2 を インストール
--&amp;gt; 依存性の処理をしています: glibc-headers = 2.17-196.el7_4.2 のパッケージ: glibc-devel-2.17-196.el7_4.2.x86_64
--&amp;gt; 依存性の処理をしています: glibc = 2.17-196.el7_4.2 のパッケージ: glibc-devel-2.17-196.el7_4.2.x86_64
--&amp;gt; 依存性の処理をしています: glibc-headers のパッケージ: glibc-devel-2.17-196.el7_4.2.x86_64
---&amp;gt; パッケージ libgcc.x86_64 0:4.8.5-11.el7 を 更新
---&amp;gt; パッケージ libgcc.x86_64 0:4.8.5-16.el7_4.1 を アップデート
---&amp;gt; パッケージ libgomp.x86_64 0:4.8.5-11.el7 を 更新
---&amp;gt; パッケージ libgomp.x86_64 0:4.8.5-16.el7_4.1 を アップデート
---&amp;gt; パッケージ libmpc.x86_64 0:1.0.1-3.el7 を インストール
--&amp;gt; トランザクションの確認を実行しています。
---&amp;gt; パッケージ glibc.x86_64 0:2.17-157.el7_3.4 を 更新
--&amp;gt; 依存性の処理をしています: glibc = 2.17-157.el7_3.4 のパッケージ: glibc-common-2.17-157.el7_3.4.x86_64
---&amp;gt; パッケージ glibc.x86_64 0:2.17-196.el7_4.2 を アップデート
---&amp;gt; パッケージ glibc-headers.x86_64 0:2.17-196.el7_4.2 を インストール
--&amp;gt; 依存性の処理をしています: kernel-headers &amp;gt;= 2.2.1 のパッケージ: glibc-headers-2.17-196.el7_4.2.x86_64
--&amp;gt; 依存性の処理をしています: kernel-headers のパッケージ: glibc-headers-2.17-196.el7_4.2.x86_64
--&amp;gt; トランザクションの確認を実行しています。
---&amp;gt; パッケージ glibc-common.x86_64 0:2.17-157.el7_3.4 を 更新
---&amp;gt; パッケージ glibc-common.x86_64 0:2.17-196.el7_4.2 を アップデート
---&amp;gt; パッケージ kernel-headers.x86_64 0:3.10.0-693.11.1.el7 を インストール
--&amp;gt; 依存性解決を終了しました。

依存性を解決しました

=======================================================================================================================================================================================
 Package                                       アーキテクチャー                      バージョン                                           リポジトリー                            容量
=======================================================================================================================================================================================
インストール中:
 gcc                                           x86_64                                4.8.5-16.el7_4.1                                     updates                                 16 M
依存性関連でのインストールをします:
 cpp                                           x86_64                                4.8.5-16.el7_4.1                                     updates                                5.9 M
 glibc-devel                                   x86_64                                2.17-196.el7_4.2                                     updates                                1.1 M
 glibc-headers                                 x86_64                                2.17-196.el7_4.2                                     updates                                676 k
 kernel-headers                                x86_64                                3.10.0-693.11.1.el7                                  updates                                6.0 M
 libmpc                                        x86_64                                1.0.1-3.el7                                          base                                    51 k
依存性関連での更新をします:
 glibc                                         x86_64                                2.17-196.el7_4.2                                     updates                                3.6 M
 glibc-common                                  x86_64                                2.17-196.el7_4.2                                     updates                                 11 M
 libgcc                                        x86_64                                4.8.5-16.el7_4.1                                     updates                                 98 k
 libgomp                                       x86_64                                4.8.5-16.el7_4.1                                     updates                                154 k

トランザクションの要約
=======================================================================================================================================================================================
インストール  1 パッケージ (+5 個の依存関係のパッケージ)
更新                       ( 4 個の依存関係のパッケージ)

総ダウンロード容量: 45 M
Is this ok [y/d/N]:

gcc をインストールする為に、9つのパッケージがインストール、アップデートされ configure が最後まで実行されるようになり、make する事が出来るようになりました。

# ./configure 
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"                                  <-- gcc のチェックをパスしました。
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

しかし次は、pcre-config がないと言われてしまいました。しかたがないので pcre をキーに検索をかけました。

# yum search pcre
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * nux-dextop: mirror.li.nux.ro
 * updates: ftp.riken.jp
================================================================================== N/S matched: pcre ==================================================================================
ghc-pcre-light-devel.x86_64 : Haskell pcre-light library development files
mingw32-pcre.noarch : MinGW Windows pcre library
mingw32-pcre-static.noarch : Static version of the mingw32-pcre library
mingw64-pcre.noarch : MinGW Windows pcre library
mingw64-pcre-static.noarch : Static version of the mingw64-pcre library
pcre-devel.i686 : Development files for pcre
pcre-devel.x86_64 : Development files for pcre
pcre-static.i686 : Static library for pcre
pcre-static.x86_64 : Static library for pcre
pcre-tools.x86_64 : Auxiliary utilities for pcre
pcre2-devel.i686 : Development files for pcre2
pcre2-devel.x86_64 : Development files for pcre2
pcre2-static.i686 : Static library for pcre2
pcre2-static.x86_64 : Static library for pcre2
pcre2-tools.x86_64 : Auxiliary utilities for pcre2
pcre2-utf16.i686 : UTF-16 variant of PCRE2
pcre2-utf16.x86_64 : UTF-16 variant of PCRE2
pcre2-utf32.i686 : UTF-32 variant of PCRE2
pcre2-utf32.x86_64 : UTF-32 variant of PCRE2
ghc-pcre-light.x86_64 : Perl5 compatible regular expression library
opensips-regex.x86_64 : RegExp via PCRE library
pcre.x86_64 : Perl-compatible regular expression library
pcre.i686 : Perl-compatible regular expression library
pcre2.i686 : Perl-compatible regular expression library
pcre2.x86_64 : Perl-compatible regular expression library

  Name and summary matches only, use "search all" for everything.

沢山出てきて分かりません。ここからは、経験値を活かして pcre-config は、pcre-devel パッケージに入っていから pcre-devel をインストールと分かるのですが、初心者にはここで詰まってしまうと思います。まあ「pcre-config centos or ubuntu」で検索すれば出てくるとは思いますが難しいです。

# yum -y install pcre-devel
# ./configure 
          :
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... /bin/pcre-config
configure: Using external PCRE library from /bin/pcre-config  <-- pcre-config のチェックはパス
     :
reating modules/dav/fs/Makefile
creating modules/dav/lock/Makefile
creating modules/mappers/Makefile
creating Makefile                  <- Makefile が作られる
creating modules/Makefile
creating srclib/Makefile
creating os/Makefile
     :
onfigure: summary of build options:

    Server Version: 2.4.29
    Install prefix: /usr/local/apache2
    C compiler:     gcc -std=gnu99
    CFLAGS:           -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E
# make     <- make コマンドが実行可能に
Making all in srclib
make[1]: ディレクトリ `/root/httpd-2.4.29/srclib' に入ります
make[1]: ディレクトリ `/root/httpd-2.4.29/srclib' から出ます
Making all in os
make[1]: ディレクトリ `/root/httpd-2.4.29/os' に入ります
Making all in unix
make[2]: ディレクトリ `/root/httpd-2.4.29/os/unix' に入ります
make[3]: ディレクトリ `/root/httpd-2.4.29/os/unix' に入ります
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -std=gnu99  -pthread      -DLINUX -D_REENTRANT -D_GNU_SOURCE     -I. -I/root/httpd-2.4.29/os/unix -I/root/httpd-2.4.29/include
-I/usr/include/apr-1 -I/root/httpd-2.4.29/modules/aaa -I/root/httpd-2.4.29/modules/cache -I/root/httpd-2.4.29/modules/core -I/root/httpd-2.4.29/modules/database -I/root/httpd-2.4.29/modules/filters
-I/root/httpd-2.4.29/modules/ldap -I/root/httpd-2.4.29/modules/loggers -I/root/httpd-2.4.29/modules/lua -I/root/httpd-2.4.29/modules/proxy -I/root/httpd-2.4.29/modules/session
-I/root/httpd-2.4.29/modules/ssl -I/root/httpd-2.4.29/modules/test -I/root/httpd-2.4.29/server -I/root/httpd-2.4.29/modules/arch/unix -I/root/httpd-2.4.29/modules/dav/main
-I/root/httpd-2.4.29/modules/generators -I/root/httpd-2.4.29/modules/mappers  -prefer-non-pic -static -c unixd.c &amp;amp;&amp;amp; touch unixd.lo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -std=gnu99  -pthread         -o libos.la -static  unixd.lo  
make[3]: ディレクトリ `/root/httpd-2.4.29/os/unix' から出ます
make[2]: ディレクトリ `/root/httpd-2.4.29/os/unix' から出ます
make[1]: ディレクトリ `/root/httpd-2.4.29/os' から出ます
Making all in server
     :

しかし apache のような沢山の機能を備えたソフトウェアをコンパイルする際、./configure を実行する時には、様々のオプションを付けて実行します。

# ./configure --help
`configure' configures this package to adapt to many kinds of systems.
                   :
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/apache2]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]
                   :
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]

非常に沢山あります。一部日本語で記述します。


./configure --prefix=/etc/httpd \                       &amp;lt;- インストール先
            --exec-prefix=/usr \                        &amp;lt;- 実行ファイルのインストール先
            --bindir=/usr/bin \                         &amp;lt;- bin ディレクトリの場所
            --sbindir=/usr/sbin \                       &amp;lt;- sbin ディレクトリの場所
            --mandir=/usr/share/man \                   &amp;lt;- man ディレクトリの場所
                         :
            --enable-ssl \                              &amp;lt;- ssl 機能を有効にする。                   (mod_ssl)
            --with-ssl \                                &amp;lt;- OpenSSL SSL/TLS toolkit を使用する。
            --enable-distcache \                        &amp;lt;- ssl 通信時に dist キャッシュを使用する。
            --enable-proxy \                            &amp;lt;- proxy 機能を有効にする。                 (mod_proxy)
            --enable-cache \                            &amp;lt;- ドキュメントキャッシュ機能を有効にする。 (mod_cache)
            --enable-disk-cache \                       &amp;lt;- ディスクキャッシュ機能を有効にする。 (mod_disk_cache)
            --enable-ldap \                             &amp;lt;- ldap 機能を有効にする。 (mod_ldap)
                         :

試しに httpd で https 通信(mod_ssl)を有効にするためのオプション –enable-ssl と –with-ssl を使用し configure を再度実行してみましょう。

# ./configure –enable-ssl –with-ssl

checking for OpenSSL… checking for user-provided OpenSSL base directory… none
checking for OpenSSL version >= 0.9.8a… FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl… configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
[/bash]

すると OpenSSL のエラーが出力されます。このメッセージは、ssl 機能を有効にしたことにより、ssl 機能を有効にする為の開発ライブラリが不足している事を示しています。

話が長くなってきたので答えを先にいいますが、openssl-devel パッケージを追加でインストールして下さい。

# yum install openssl-devel

これで、./configure –enable-ssl –with-ssl コマンドが実行できるようになります。

ちなみに devel パッケージには、主に C, C++ 言語でのプログラミングで使われるヘッダーファイルなどが含まれています。

LINEで送る
Pocket

  • このエントリーをはてなブックマークに追加

アマゾン

LINEで送る
Pocket

記事が面白かった。為になったと思ったら。下記リンクより商品を購入頂くと筆者は喜び記事を更新致します。


LINEで送る
Pocket

コメントを残す

*

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください