0

デフォルトの GUI インストーラーを使用して MSYS と MinGW をインストールし、すべてのチェックボックスをオンにしました。次に、簡単な hello world プログラムを作成し、MSYS コマンド ラインでコンパイルしてみました。これが起こることです:

$ gcc test.c
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: 
   cannot find -lshell32
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: 
   cannot find -luser32
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: 
   cannot find -lkernel32
collect2: ld returned 1 exit status

詳細フラグを使用する場合:

$ gcc -v test.c
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/cc1.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.6.2/ test.c -quiet -dumpbase test.c -mtune=i386 -march=i386 -auxbase test -version -o C:\DOCUME~1\Owner\LOCALS~1\Temp\ccz34YZu.s
GNU C (GCC) version 4.6.2 (mingw32)
    compiled by GNU C version 4.6.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=82 --param ggc-min-heapsize=98237
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.6.2/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include-fixed
End of search list.
GNU C (GCC) version 4.6.2 (mingw32)
    compiled by GNU C version 4.6.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=82 --param ggc-min-heapsize=98237
Compiler executable checksum: c20aed7c018482d7b62efcd5dcab2a9d
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/as.exe -o C:\DOCUME~1\Owner\LOCALS~1\Temp\ccgcJLdQ.o C:\DOCUME~1\Owner\LOCALS~1\Temp\ccz34YZu.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.6.2/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../;/mingw/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/collect2.exe -Bdynamic c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../.. -L/mingw/lib C:\DOCUME~1\Owner\LOCALS~1\Temp\ccgcJLdQ.o -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtend.o
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lshell32
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -luser32
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lkernel32
collect2: ld returned 1 exit status

私は何を間違えましたか?Microsoft 開発ライブラリが必要ですか? 必要な場合、どこで入手できますか?

4

1 に答える 1

0

mingw と MSYS をインストールしたときに、すべての環境変数が適切に設定されているかどうかを確認してください。

于 2013-07-01T19:24:06.760 に答える