質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

GCC

GCCはGNU Compiler Collectionの略です。LinuxのC言語コンパイラのデファクトスタンダードであり、数多くの他言語やプラットフォームサポートもします。

makefile

make は、プログラムのビルド作業を自動化するツールです。コンパイル、リンク、インストール等のルールを記述したテキストファイルをmakefileと呼び、このルールに従ってmakeが自動的にビルドを実行する。

MinGW

MinGW(ミン・ジー・ダブリュー)は GNUツールチェーンのWindows移植版です。 ランタイムライブラリと開発ツールで構成されています。

Q&A

解決済

2回答

12992閲覧

msys2上でconfigureを実行するとエラーになる

imudak

総合スコア40

C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

GCC

GCCはGNU Compiler Collectionの略です。LinuxのC言語コンパイラのデファクトスタンダードであり、数多くの他言語やプラットフォームサポートもします。

makefile

make は、プログラムのビルド作業を自動化するツールです。コンパイル、リンク、インストール等のルールを記述したテキストファイルをmakefileと呼び、このルールに従ってmakeが自動的にビルドを実行する。

MinGW

MinGW(ミン・ジー・ダブリュー)は GNUツールチェーンのWindows移植版です。 ランタイムライブラリと開発ツールで構成されています。

0グッド

0クリップ

投稿2016/06/27 01:56

編集2016/06/29 02:03

###前提・実現したいこと

  • 最終的にはLinuxでbuildするプロジェクトのソースコードを、開発中は簡単のためWindowsでもbuildできるようにしたい。
  • このため、msys2上でconfigureを実行したい。

###発生している問題・エラーメッセージ
Windows8.1(64bit)にmsys2(64bit)をインストールし、単純なhello worldプロジェクトを起こしてautconfなどで設定後、configureを実行するとエラーになります。

$ ./configure checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/home/imudak/hello': configure: error: C compiler cannot create executables See `config.log' for more details

###該当のソースコード
src/helloc.c

#include <stdio.h> int main(int argc, char** argv) { printf("Hello, autoconf!\n"); return 0; }

configure.ac

# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT([hello], [0.0.1], [BUG-REPORT-ADDRESS]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([src/hello.c]) AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT

src/Makefile.am

bin_PROGRAMS=hello hello_SOURCES=hello.c

Makefile.am

SUBDIRS=src

###試したこと

をgit cloneしてconfigureを実行しても同様のエラーになります。

  • msys2の再インストールしても状況は変わりません。
  • MSYSTEM=MSYS2, MSYSTEM=MINGW64, MSYSTEM=MINGW32 のどれで実行しても、エラーの内容は同じです。
  • 直接gccは問題なく実行できます。以下hello worldの例です。
$ gcc src/hello.c $ ./a.exe Hello, autoconf!
  • linux(ubuntu16.04LTS)で同じconfigureを実行すると問題ありません。生成されたMakefileをmsys2側に持ってきてmakeすると問題なく実行できます。

  • gcc -vで表示される引数を与えてconfigureを実行してもダメでした。

$ ./configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-li bgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable -__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic - -enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --disabl e-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without -libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compat ible configure: WARNING: unrecognized options: --enable-bootstrap, --enable-shared, --enable-shared-libgcc, --enable-static, --enable-version-specific-runtime-libs, --with-arch, --with-tune, --disable-multilib, --enable-__cxa_atexit, --with-dwarf2, --enable-languages, --enable-graphite, --enable-threads, --enable-libatomic, --enable-libcilkrts, --enable-libgomp, --enable-libitm, --enable-libquadmath, --enable-libquadmath-support, --enable-libssp, --disable-win32-registry, --disable-symvers, --with-gnu-ld, --with-gnu-as, --disable-isl-version-check, --enable-checking, --without-libiconv-prefix, --without-libintl-prefix, --with-system-zlib, --enable-linker-build-id, --with-default-libstdcxx-abi checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/home/imudak/hello': configure: error: C compiler cannot create executables See `config.log' for more details

###補足情報(言語/FW/ツール等のバージョンなど)

config.logの該当箇所を載せておきます。

## ----------- ## ## Core tests. ## ## ----------- ## configure:1832: checking for a BSD-compatible install configure:1900: result: /usr/bin/install -c configure:1911: checking whether build environment is sane configure:1966: result: yes configure:2117: checking for a thread-safe mkdir -p configure:2156: result: /usr/bin/mkdir -p configure:2163: checking for gawk configure:2179: found /usr/bin/gawk configure:2190: result: gawk configure:2201: checking whether make sets $(MAKE) configure:2223: result: yes configure:2252: checking whether make supports nested variables configure:2269: result: yes configure:2448: checking for gcc configure:2464: found /usr/bin/gcc configure:2475: result: gcc configure:2704: checking for C compiler version configure:2713: gcc --version >&5 gcc (GCC) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:2724: $? = 0 configure:2713: gcc -v >&5 Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/5.3.0/lto-wrapper.exe Target: x86_64-pc-msys Configured with: /msys_scripts/gcc/src/gcc-5.3.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible Thread model: posix gcc version 5.3.0 (GCC) configure:2724: $? = 0 configure:2713: gcc -V >&5 gcc: error: unrecognized command line option '-V' gcc: fatal error: no input files compilation terminated. configure:2724: $? = 1 configure:2713: gcc -qversion >&5 gcc: error: unrecognized command line option '-qversion' gcc: fatal error: no input files compilation terminated. configure:2724: $? = 1 configure:2744: checking whether the C compiler works configure:2766: configure:2770: $? = 1 configure:2808: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "hello" | #define PACKAGE_TARNAME "hello" | #define PACKAGE_VERSION "0.0.1" | #define PACKAGE_STRING "hello 0.0.1" | #define PACKAGE_BUGREPORT "BUG-REPORT-ADDRESS" | #define PACKAGE_URL "" | #define PACKAGE "hello" | #define VERSION "0.0.1" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:2813: error: in `/home/imudak/hello': configure:2815: error: C compiler cannot create executables See `config.log' for more details

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

PCをWindows10にしたところ再現しなくなってしまったので、いったん閉じます。

投稿2016/10/20 06:50

imudak

総合スコア40

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

こんにちは。

回答には辿りつけなかったのですが、ヒントにはなるかも知れないので情報提供です。
様々な環境で同様なエラーに悩んでいる人は多いようです。

autoconf complains “C compiler cannot create executables” on Linux Mint
上記、QAを見ると-Vや-qversionは古いgccがサポートしていたオプションでその有無をチェックしているだけなので、この2つのエラーは無視して良いそうです。
そして、C compiler cannot create executablesの原因を探せと書かれてますが、他にエラー原因が見当たらないように見えます。
configure:2813: error: in '/home/imudak/hello':がちょっと気になります。エラーの出た時のフォルダが書かれているようなので、念のためこのフォルダ配下へmsys2環境で書き込めるのか確認しておくと良さそうです。

CFLAGSを誤記して"configure: error: C compiler cannot create executables"と言われた話
↑のような事例もあるので環境変数のCFLAGSも確認されてみて下さい。

投稿2016/06/29 02:00

編集2016/06/29 02:10
Chironian

総合スコア23272

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

imudak

2016/06/29 02:59 編集

回答ありがとうございます。 > configure:2813: error: in '/home/imudak/hello':がちょっと気になります。エラーの出た時のフォルダが書かれているようなので、念のためこのフォルダ配下へmsys2環境で書き込めるのか確認しておくと良さそうです。 試しにconfigureから抜き出した以下のようなスクリプトを書いて実行してみましたが、 意図したファイルは作られているようです。 test: --------------------- #! /bin/sh # Define the identity of the package. PACKAGE='hello' VERSION='0.0.1' ac_ext=c cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF gcc conftest.c --------------------- 実行結果: --------------------- $ ls aclocal.m4 compile config.log configure.ac install-sh Makefile.in src autom4te.cache config.h.in configure depcomp Makefile.am missing test $ ./test $ ls a.exe autom4te.cache confdefs.h config.log configure.ac depcomp Makefile.am missing test aclocal.m4 compile config.h.in configure conftest.c install-sh Makefile.in src ---------------------
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問