前回、libnlをクロスコンパイルしようとしたらconfigureでエラー発生。継続調査中。

【関連記事】
【組込ボードで無線LAN】②(無線LANカードN-6300を組込ボードに接続するには?)
【組込ボードで無線LAN】⑧(iwのビルド:後編-1)
  • libnlをクロスコンパイルしたらエラー発生
前回、クロスコンパイル向け環境変数設定の後、libnlのconfigureを実行したら以下のエラーが発生。--hostというオプションを指定する必要がありそうなので調べてみた。
$ . /opt/poky/1.8.2/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
$ cd ~/libnl-3.4.0/
./configure
configure: loading site script /opt/poky/1.8.2/site-config-cortexa9hf-vfp-neon-poky-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
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... configure: error: in `/home/pavement1234/libnl-3.4.0':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

configureのbuild、host、targetの違いを読んだ。まず、この方は--build、--host、--targetの定義をこうしている。--hostとはmakeして作ったプログラムの実行環境とある。
--build     コンパイルPC
--host     makeして作ったプログラムの実行環境
--target     クロス開発におけるターゲット環境
次にconfigureのヘルプ(--help)を見てみた。--buildと--hostの記載があるので参考にする。
$ ./configure --help
`configure' configures libnl 3.4.0 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

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/libnl]
  --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]


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-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-static[=PKGS]  build static libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-cli=yes|no|no-inst|bin|sbin
                          Whether to build command line interface utils.
                          Defaults to 'yes' which is a synonym for 'bin'.
                          'no-inst' means only build, not installing.
                          'bin'/'sbin' means installing to bin/sbin directory
  --disable-pthreads      Disable pthreads support
  --disable-debug         Do not include debugging statements

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-aix-soname=aix|svr4|both
                          shared library versioning (aka "SONAME") variant to
                          provide on AIX, [default=aix].
  --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-pkgconfigdir=PATH
                          Path to the pkgconfig directory [[LIBDIR/pkgconfig]]

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>
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.
  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
  CHECK_CFLAGS
              C compiler flags for CHECK, overriding pkg-config
  CHECK_LIBS  linker flags for CHECK, 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.

Report bugs to the package provider.
libnl home page: <http://www.infradead.org/~tgr/libnl/>.
--hostに/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabiを指定してconfigure実行してみると...。前回エラーになったところはパスしたものの、もうちょっと進んだところでまたエラー発生。checking host system type... Invalid configurationと言っている。
$ cd ~/libnl-3.4.0
$ ./configure --host=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
neon-poky-linux-gnueabi
configure: loading site script /opt/poky/1.8.2/site-config-cortexa9hf-vfp-neon-poky-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi-strip... arm-poky-linux-gnueabi-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi-gcc... arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
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... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi accepts -g... yes
checking for arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi option to accept ISO C89... none needed
checking whether arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi understands -c and -o together... yes
checking dependency style of arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi... gcc3
checking for /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi-ar... arm-poky-linux-gnueabi-ar
checking the archiver (arm-poky-linux-gnueabi-ar) interface... ar
checking for /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi-gcc... (cached) arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
checking whether we are using the GNU C compiler... (cached) yes
checking whether arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi accepts -g... (cached) yes
checking for arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi option to accept ISO C89... (cached) none needed
checking whether arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi understands -c and -o together... (cached) yes
checking dependency style of arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi... (cached) gcc3
checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration `/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi': machine `/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky' not recognized
configure: error: /bin/bash build-aux/config.sub /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi failed

さて。どうしたものか。まずchecking host system type... Invalid configurationで検索してみた。configure時に「Invalid configuration 'X86_64-unknown-linux-gnu'」なエラーが出たらというページがgoogle検索のTOPに出てきたので読んだ。こんなことが書いてある。どうやらconfig.subというシェルスクリプトを使ってhostのシステムタイプを判定するらしい。
configureスクリプトはMakefileを生成する際に、ユーザが指定しなかったhost・target・builed system typeを推定する「config.guess」というshellスクリプトと、推定結果から正規化されたhost system typeを生成する「config.sub」というshellスクリプトのセットを使って、host system typeを判別しています。
このセットはアプリケーションを配布する際にソースコードに付与する必要があるのですが、それらが環境に適合していないと、type判別ができないため上記のエラー文が出てしまいます。
たしかに、configureのエラーメッセージにconfigure: error: /bin/bash build-aux/config.sub /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi failedと出てた。

さらに、libnlのディレクトリ直下にbuild-auxというディレクトリがあり、config.subがあった。

ちょっと整理すると、configureを実行するとconfig.guessによりhost、target、buildシステムタイプが推定され、次にconfg.subによりhostマシンタイプ名を生成しようとするが、指定したマシン(/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky)はダメ(not recognized)と判定された。ということか。

さらにconfigure時に「Invalid configuration 'X86_64-unknown-linux-gnu'」なエラーが出たらを読み進めると、こんなことが書いてある。
そんなときは、いろいろな対処方法がありますが、「/usr/share/libtool/config.guess」と「/usr/share/libtool/config.sub」を、configureが存在するディレクトリにコピーします。その後、configureを普通に実行します。

cd 目的のディレクトリ
cp /usr/share/libtool/config.guess .
cp /usr/share/libtool/config.sub .
./configure [some options]


そうすると、エラーが回避されてmakeに取りかかれます。やりました。
このケースではホストPC環境の/usr/share/libtool/config.guess/usr/share/libtool/config.subをconfigureと同じディレクトリにコピーしたらconfigureがうまく行ったと言っている。

私の環境に当てはめると、ARMのSDKにあるconfig.guess、configu.subをlibnl直下にあるconfig.guess、configu.subに上書きする、になると理解。
$ cd ~/libnl-3.4.0
$ mv build-aux build-aux_bk 念のためバックアップ
$ cp -r /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/share/libtool/build-aux/ .
再びconfigureを実行したが結果は同じ(エラー)。なかなか手ごわい。次回も継続調査しようと思う。

続く

IMG_20191001_081330

スポンサードリンク