C mingw

以前はうまくいったのですが、今回Windows10ではうまくいかなかったので、別の方法にします。EclipseもNeonにしました。

mingwをインストールします。「Install」ボタンクリック後は、「Continue」ボタンで各パッケージの選択画面まで進めます。

「mingw-developer-toolkit」、「mingw32-base」、「mingw32-gcc-g++」及び「msys-base」の各行を選択し、右クリックで「Mark for Installaion」を選択し、チェック状態にします。

「Installation」を選択し、「Apply Changes」を選択し、表示される画面で「Apply」を選択しインストールします。

うまくいくと、こんな画面になるので「Close」をクリックして完了です。

以下の環境変数をWindowsの環境変数に設定する。

PATH %MINGW_HOME%\bin
%MSYS_HOME%\bin
MINGW_HOME インストールドライブ:\MinGw
MSYS_HOME インストールドライブ:\MinGw\msys\1.0

MinGwをインストールしたドライブ直下にディレクトリcunitを作ってそこにCUnit-2.1-2-src.tar.bz2をコピーします。

インストールドライブ\MinGW\mys\1.0\msys.batからコンソールを立ち上げます。

以下のコマンドを入力していきます。

cd  /コピーしたドライブ/cunit

bunzip2.exe CUnit-2.1-2-src.tar.bz2

tar -xvf CUnit-2.1-2-src.tar

$ cd /d/cunit
$ bunzip2.exe CUnit-2.1-2-src.tar.bz2
$ tar -xvf CUnit-2.1-2-src.tar
CUnit-2.1-2/
CUnit-2.1-2/NEWS
CUnit-2.1-2/Makefile.am
CUnit-2.1-2/configure
CUnit-2.1-2/cunit.pc.in
CUnit-2.1-2/TODO
CUnit-2.1-2/INSTALL
CUnit-2.1-2/Man/
CUnit-2.1-2/Man/man3/
CUnit-2.1-2/Man/man3/Makefile.am
CUnit-2.1-2/Man/man3/Makefile.in
CUnit-2.1-2/Man/man3/CUnit.3
CUnit-2.1-2/Man/Makefile.am
CUnit-2.1-2/Man/Makefile.in
CUnit-2.1-2/depcomp
CUnit-2.1-2/aclocal.m4
CUnit-2.1-2/Makefile.in
CUnit-2.1-2/mkinstalldirs
CUnit-2.1-2/ltmain.sh
CUnit-2.1-2/README
CUnit-2.1-2/install-sh
CUnit-2.1-2/CUnit.spec.in
CUnit-2.1-2/Examples/
CUnit-2.1-2/Examples/Makefile.am
CUnit-2.1-2/Examples/WinTest/
CUnit-2.1-2/Examples/WinTest/WinTest.cpp
CUnit-2.1-2/Examples/WinTest/StdAfx.h
CUnit-2.1-2/Examples/WinTest/WinTest_v1.cpp
CUnit-2.1-2/Examples/WinTest/WinTest.dsp
CUnit-2.1-2/Examples/WinTest/StdAfx.cpp
CUnit-2.1-2/Examples/WinTest/ReadMe.txt
CUnit-2.1-2/Examples/Makefile.in
CUnit-2.1-2/Examples/AutomatedTest/
CUnit-2.1-2/Examples/AutomatedTest/Makefile.am
CUnit-2.1-2/Examples/AutomatedTest/AutomatedTest.c
CUnit-2.1-2/Examples/AutomatedTest/Makefile.in
CUnit-2.1-2/Examples/AutomatedTest/README
CUnit-2.1-2/Examples/BasicTest/
CUnit-2.1-2/Examples/BasicTest/Makefile.am
CUnit-2.1-2/Examples/BasicTest/Makefile.in
CUnit-2.1-2/Examples/BasicTest/BasicTest.c
CUnit-2.1-2/Examples/BasicTest/README
CUnit-2.1-2/Examples/ConsoleTest/
CUnit-2.1-2/Examples/ConsoleTest/Makefile.am
CUnit-2.1-2/Examples/ConsoleTest/Makefile.in
CUnit-2.1-2/Examples/ConsoleTest/README
CUnit-2.1-2/Examples/ConsoleTest/ConsoleTest.c
CUnit-2.1-2/Examples/CursesTest/
CUnit-2.1-2/Examples/CursesTest/Makefile.am
CUnit-2.1-2/Examples/CursesTest/Makefile.in
CUnit-2.1-2/Examples/CursesTest/CursesTest.c
CUnit-2.1-2/Examples/CursesTest/README
CUnit-2.1-2/Examples/ExampleTests.c
CUnit-2.1-2/Share/
CUnit-2.1-2/Share/Makefile.am
CUnit-2.1-2/Share/CUnit-Run.xsl
CUnit-2.1-2/Share/Makefile.in
CUnit-2.1-2/Share/Memory-Dump.xsl
CUnit-2.1-2/Share/md2xml.pl
CUnit-2.1-2/Share/CUnit-List.dtd
CUnit-2.1-2/Share/Memory-Dump.dtd
CUnit-2.1-2/Share/CUnit-Run.dtd
CUnit-2.1-2/Share/CUnit-List.xsl
CUnit-2.1-2/config.guess
CUnit-2.1-2/doc/
CUnit-2.1-2/doc/headers/
CUnit-2.1-2/doc/headers/wxWidget.h
CUnit-2.1-2/doc/headers/CUCurses.h
CUnit-2.1-2/doc/headers/Automated.h
CUnit-2.1-2/doc/headers/Basic.h
CUnit-2.1-2/doc/headers/Makefile.am
CUnit-2.1-2/doc/headers/TestRun.h
CUnit-2.1-2/doc/headers/CUError.h
CUnit-2.1-2/doc/headers/Makefile.in
CUnit-2.1-2/doc/headers/TestDB.h
CUnit-2.1-2/doc/headers/Console.h
CUnit-2.1-2/doc/headers/MyMem.h
CUnit-2.1-2/doc/headers/Util.h
CUnit-2.1-2/doc/headers/CUnit.h
CUnit-2.1-2/doc/headers/Win.h
CUnit-2.1-2/doc/headers/CUnit_intl.h
CUnit-2.1-2/doc/test_registry.html
CUnit-2.1-2/doc/Makefile.am
CUnit-2.1-2/doc/writing_tests.html
CUnit-2.1-2/doc/managing_tests.html
CUnit-2.1-2/doc/fdl.html
CUnit-2.1-2/doc/Makefile.in
CUnit-2.1-2/doc/error_handling.html
CUnit-2.1-2/doc/index.html
CUnit-2.1-2/doc/introduction.html
CUnit-2.1-2/doc/CUnit_doc.css
CUnit-2.1-2/doc/running_tests.html
CUnit-2.1-2/missing
CUnit-2.1-2/configure.in
CUnit-2.1-2/ChangeLog
CUnit-2.1-2/AUTHORS
CUnit-2.1-2/config.sub
CUnit-2.1-2/Jamrules.in
CUnit-2.1-2/CUnit/
CUnit-2.1-2/CUnit/Headers/
CUnit-2.1-2/CUnit/Headers/CUCurses.h
CUnit-2.1-2/CUnit/Headers/Automated.h
CUnit-2.1-2/CUnit/Headers/Basic.h
CUnit-2.1-2/CUnit/Headers/Makefile.am
CUnit-2.1-2/CUnit/Headers/TestRun.h
CUnit-2.1-2/CUnit/Headers/CUnit.h.in
CUnit-2.1-2/CUnit/Headers/CUError.h
CUnit-2.1-2/CUnit/Headers/Makefile.in
CUnit-2.1-2/CUnit/Headers/TestDB.h
CUnit-2.1-2/CUnit/Headers/Console.h
CUnit-2.1-2/CUnit/Headers/MyMem.h
CUnit-2.1-2/CUnit/Headers/Util.h
CUnit-2.1-2/CUnit/Headers/CUnit.h
CUnit-2.1-2/CUnit/Headers/CUnit_intl.h
CUnit-2.1-2/CUnit/Makefile.am
CUnit-2.1-2/CUnit/Makefile.in
CUnit-2.1-2/CUnit/Sources/
CUnit-2.1-2/CUnit/Sources/Test/
CUnit-2.1-2/CUnit/Sources/Test/Makefile.am
CUnit-2.1-2/CUnit/Sources/Test/test_cunit.c
CUnit-2.1-2/CUnit/Sources/Test/Makefile.in
CUnit-2.1-2/CUnit/Sources/Framework/
CUnit-2.1-2/CUnit/Sources/Framework/Util.c
CUnit-2.1-2/CUnit/Sources/Framework/Makefile.am
CUnit-2.1-2/CUnit/Sources/Framework/Makefile.in
CUnit-2.1-2/CUnit/Sources/Framework/MyMem.c
CUnit-2.1-2/CUnit/Sources/Framework/TestRun.c
CUnit-2.1-2/CUnit/Sources/Framework/TestDB.c
CUnit-2.1-2/CUnit/Sources/Framework/CUError.c
CUnit-2.1-2/CUnit/Sources/Makefile.am
CUnit-2.1-2/CUnit/Sources/Win/
CUnit-2.1-2/CUnit/Sources/Win/resource.h
CUnit-2.1-2/CUnit/Sources/Win/Win.c
CUnit-2.1-2/CUnit/Sources/Win/Win.h
CUnit-2.1-2/CUnit/Sources/Makefile.in
CUnit-2.1-2/CUnit/Sources/Basic/
CUnit-2.1-2/CUnit/Sources/Basic/Makefile.am
CUnit-2.1-2/CUnit/Sources/Basic/Basic.c
CUnit-2.1-2/CUnit/Sources/Basic/Makefile.in
CUnit-2.1-2/CUnit/Sources/Console/
CUnit-2.1-2/CUnit/Sources/Console/Makefile.am
CUnit-2.1-2/CUnit/Sources/Console/Makefile.in
CUnit-2.1-2/CUnit/Sources/Console/Console.c
CUnit-2.1-2/CUnit/Sources/Curses/
CUnit-2.1-2/CUnit/Sources/Curses/Makefile.am
CUnit-2.1-2/CUnit/Sources/Curses/Makefile.in
CUnit-2.1-2/CUnit/Sources/Curses/Curses.c
CUnit-2.1-2/CUnit/Sources/Automated/
CUnit-2.1-2/CUnit/Sources/Automated/Automated.c
CUnit-2.1-2/CUnit/Sources/Automated/Makefile.am
CUnit-2.1-2/CUnit/Sources/Automated/Makefile.in
CUnit-2.1-2/config.h.in
CUnit-2.1-2/COPYING

cd CUnit-2.1-2
$ cd CUnit-2.1-2

mountで、インストールしたパスとMinGW上でのひも付を確認します。以下では「/mingw」が該当します。

$ mount
C:\Users\ユーザ名\AppData\Local\Temp on /tmp type user (binmode,noumount)
D:\MinGW\msys\1.0 on /usr type user (binmode,noumount)
D:\MinGW\msys\1.0 on / type user (binmode,noumount)
D:\MinGW on /mingw type user (binmode)
c: on /c type user (binmode,noumount)
d: on /d type user (binmode,noumount)

./configure –prefix=/mingw

$ ./configure --prefix=/mingw
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
/d/cunit/CUnit-2.1-2/missing: Unknown `--run' option
Try `/d/cunit/CUnit-2.1-2/missing --help' for more information
configure: WARNING: `missing' script is too old or missing
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
---------- Disabling debug mode compilation.
++++++++++ Enabling automated(XML) mode compilation
++++++++++ Enabling basic mode compilation
++++++++++ Enabling console mode compilation
---------- Disabling curses mode compilation
---------- Disabling examples mode compilation
---------- Disabling test mode compilation
---------- Disabling memtrace functionality at compile time
---------- Disabling use of deprecated v1.1 names
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
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 for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... d:/mingw/mingw32/bin/ld.exe
checking if the linker (d:/mingw/mingw32/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /mingw/bin/nm
checking the name lister (/mingw/bin/nm) interface... BSD nm
checking whether ln -s works... no, using cp -p
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for d:/mingw/mingw32/bin/ld.exe option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /mingw/bin/nm output from gcc object... ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (d:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for main in -lc... no
checking for malloc... yes
checking for free... yes
checking for calloc... yes
checking for realloc... yes
checking for strcpy... yes
checking for strerror... yes
checking for fopen... yes
checking for fclose... yes
checking for fprintf... yes
checking for setvbuf... yes
checking for time... yes
checking for ctime... yes
checking for ANSI C header files... (cached) yes
checking assert.h usability... yes
checking assert.h presence... yes
checking for assert.h... yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking file.h usability... no
checking file.h presence... no
checking for file.h... no
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for an ANSI C-conforming const... yes
configure: creating ./config.status
config.status: creating Jamrules
config.status: creating Makefile
config.status: creating CUnit.spec
config.status: creating cunit.pc
config.status: creating CUnit/Makefile
config.status: creating CUnit/Headers/Makefile
config.status: creating CUnit/Headers/CUnit.h
config.status: creating CUnit/Sources/Makefile
config.status: creating CUnit/Sources/Framework/Makefile
config.status: creating CUnit/Sources/Automated/Makefile
config.status: creating CUnit/Sources/Basic/Makefile
config.status: creating CUnit/Sources/Console/Makefile
config.status: creating CUnit/Sources/Curses/Makefile
config.status: creating CUnit/Sources/Test/Makefile
config.status: creating doc/Makefile
config.status: creating doc/headers/Makefile
config.status: creating Examples/Makefile
config.status: creating Examples/AutomatedTest/Makefile
config.status: creating Examples/BasicTest/Makefile
config.status: creating Examples/ConsoleTest/Makefile
config.status: creating Examples/CursesTest/Makefile
config.status: creating Man/Makefile
config.status: creating Man/man3/Makefile
config.status: creating Share/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
$

make install

$ make install
Making install in CUnit
make[1]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit'
Making install in Sources
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
Making install in Framework
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Framework'
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT CUError.lo -MD -MP -MF .deps/CUError.Tpo -c -o CUError.lo CUError.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT CUError.lo -MD -MP -MF .deps/CUError.Tpo -c CUError.c -DDLL_EXPORT -DPIC -o .libs/CUError.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT CUError.lo -MD -MP -MF .deps/CUError.Tpo -c CUError.c -o CUError.o >/dev/null 2>&1
mv -f .deps/CUError.Tpo .deps/CUError.Plo
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT MyMem.lo -MD -MP -MF .deps/MyMem.Tpo -c -o MyMem.lo MyMem.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT MyMem.lo -MD -MP -MF .deps/MyMem.Tpo -c MyMem.c -DDLL_EXPORT -DPIC -o .libs/MyMem.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT MyMem.lo -MD -MP -MF .deps/MyMem.Tpo -c MyMem.c -o MyMem.o >/dev/null 2>&1
mv -f .deps/MyMem.Tpo .deps/MyMem.Plo
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestDB.lo -MD -MP -MF .deps/TestDB.Tpo -c -o TestDB.lo TestDB.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestDB.lo -MD -MP -MF .deps/TestDB.Tpo -c TestDB.c -DDLL_EXPORT -DPIC -o .libs/TestDB.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestDB.lo -MD -MP -MF .deps/TestDB.Tpo -c TestDB.c -o TestDB.o >/dev/null 2>&1
mv -f .deps/TestDB.Tpo .deps/TestDB.Plo
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestRun.lo -MD -MP -MF .deps/TestRun.Tpo -c -o TestRun.lo TestRun.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestRun.lo -MD -MP -MF .deps/TestRun.Tpo -c TestRun.c -DDLL_EXPORT -DPIC -o .libs/TestRun.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT TestRun.lo -MD -MP -MF .deps/TestRun.Tpo -c TestRun.c -o TestRun.o >/dev/null 2>&1
mv -f .deps/TestRun.Tpo .deps/TestRun.Plo
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Util.lo -MD -MP -MF .deps/Util.Tpo -c -o Util.lo Util.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Util.lo -MD -MP -MF .deps/Util.Tpo -c Util.c -DDLL_EXPORT -DPIC -o .libs/Util.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Util.lo -MD -MP -MF .deps/Util.Tpo -c Util.c -o Util.o >/dev/null 2>&1
mv -f .deps/Util.Tpo .deps/Util.Plo
/bin/sh ../../../libtool --tag=CC --mode=link gcc -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -L/d/cunit/CUnit-2.1-2/CUnit/Sources -o libcunitfmk.la CUError.lo MyMem.lo TestDB.lo TestRun.lo Util.lo
libtool: link: ar cru .libs/libcunitfmk.a .libs/CUError.o .libs/MyMem.o .libs/TestDB.o .libs/TestRun.o .libs/Util.o
libtool: link: ranlib .libs/libcunitfmk.a
libtool: link: ( cd ".libs" && rm -f "libcunitfmk.la" && cp -p "../libcunitfmk.la" "libcunitfmk.la" )
make[4]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Framework'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Framework'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Framework'
Making install in Automated
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Automated'
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Automated.lo -MD -MP -MF .deps/Automated.Tpo -c -o Automated.lo Automated.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Automated.lo -MD -MP -MF .deps/Automated.Tpo -c Automated.c -DDLL_EXPORT -DPIC -o .libs/Automated.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Automated.lo -MD -MP -MF .deps/Automated.Tpo -c Automated.c -o Automated.o >/dev/null 2>&1
mv -f .deps/Automated.Tpo .deps/Automated.Plo
/bin/sh ../../../libtool --tag=CC --mode=link gcc -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -L/d/cunit/CUnit-2.1-2/CUnit/Sources -o libcunitautomated.la Automated.lo
libtool: link: ar cru .libs/libcunitautomated.a .libs/Automated.o
libtool: link: ranlib .libs/libcunitautomated.a
libtool: link: ( cd ".libs" && rm -f "libcunitautomated.la" && cp -p "../libcunitautomated.la" "libcunitautomated.la" )
make[4]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Automated'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Automated'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Automated'
Making install in Basic
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Basic'
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Basic.lo -MD -MP -MF .deps/Basic.Tpo -c -o Basic.lo Basic.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Basic.lo -MD -MP -MF .deps/Basic.Tpo -c Basic.c -DDLL_EXPORT -DPIC -o .libs/Basic.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Basic.lo -MD -MP -MF .deps/Basic.Tpo -c Basic.c -o Basic.o >/dev/null 2>&1
mv -f .deps/Basic.Tpo .deps/Basic.Plo
/bin/sh ../../../libtool --tag=CC --mode=link gcc -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -L/d/cunit/CUnit-2.1-2/CUnit/Sources -o libcunitbasic.la Basic.lo
libtool: link: ar cru .libs/libcunitbasic.a .libs/Basic.o
libtool: link: ranlib .libs/libcunitbasic.a
libtool: link: ( cd ".libs" && rm -f "libcunitbasic.la" && cp -p "../libcunitbasic.la" "libcunitbasic.la" )
make[4]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Basic'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Basic'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Basic'
Making install in Console
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Console'
/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Console.lo -MD -MP -MF .deps/Console.Tpo -c -o Console.lo Console.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Console.lo -MD -MP -MF .deps/Console.Tpo -c Console.c -DDLL_EXPORT -DPIC -o .libs/Console.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -MT Console.lo -MD -MP -MF .deps/Console.Tpo -c Console.c -o Console.o >/dev/null 2>&1
mv -f .deps/Console.Tpo .deps/Console.Plo
/bin/sh ../../../libtool --tag=CC --mode=link gcc -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -L/d/cunit/CUnit-2.1-2/CUnit/Sources -o libcunitconsole.la Console.lo
libtool: link: ar cru .libs/libcunitconsole.a .libs/Console.o
libtool: link: ranlib .libs/libcunitconsole.a
libtool: link: ( cd ".libs" && rm -f "libcunitconsole.la" && cp -p "../libcunitconsole.la" "libcunitconsole.la" )
make[4]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Console'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Console'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources/Console'
Making install in .
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
/bin/sh ../../libtool --tag=CC --mode=link gcc -DRELEASE=@RELEASE@ -Wall -W -pedantic -Wshadow -ansi -I/d/cunit/CUnit-2.1-2/CUnit/Headers -version-info 1:1:0 -L/d/cunit/CUnit-2.1-2/CUnit/Sources -o libcunit.la -rpath /mingw/lib Framework/CUError.lo Framework/MyMem.lo Framework/TestDB.lo Framework/TestRun.lo Framework/Util.lo Automated/Automated.lo Basic/Basic.lo Console/Console.lo
libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared libraries
libtool: link: ar cru .libs/libcunit.a Framework/CUError.o Framework/MyMem.o Framework/TestDB.o Framework/TestRun.o Framework/Util.o Automated/Automated.o Basic/Basic.o Console/Console.o
libtool: link: ranlib .libs/libcunit.a
libtool: link: ( cd ".libs" && rm -f "libcunit.la" && cp -p "../libcunit.la" "libcunit.la" )
make[4]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
test -z "/mingw/lib" || /bin/mkdir -p "/mingw/lib"
 /bin/sh ../../libtool --mode=install /bin/install -c libcunit.la '/mingw/lib'
libtool: install: /bin/install -c .libs/libcunit.lai /mingw/lib/libcunit.la
libtool: install: /bin/install -c .libs/libcunit.a /mingw/lib/libcunit.a
libtool: install: chmod 644 /mingw/lib/libcunit.a
libtool: install: ranlib /mingw/lib/libcunit.a
----------------------------------------------------------------------
Libraries have been installed in:
 /mingw/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
 - add LIBDIR to the `PATH' environment variable
 during execution
 - add LIBDIR to the `LD_RUN_PATH' environment variable
 during linking
 - use the `-LLIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Sources'
Making install in Headers
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Headers'
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit/Headers'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/mingw/include/CUnit" || /bin/mkdir -p "/mingw/include/CUnit"
 /bin/install -c -m 644 CUError.h CUnit.h CUnit_intl.h MyMem.h TestDB.h TestRun.h Util.h Basic.h Console.h Automated.h '/mingw/include/CUnit'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Headers'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit/Headers'
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit'
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/CUnit'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit'
make[1]: Leaving directory `/d/cunit/CUnit-2.1-2/CUnit'
Making install in doc
make[1]: Entering directory `/d/cunit/CUnit-2.1-2/doc'
Making install in headers
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/doc/headers'
cp -f ../../CUnit/Headers/*.h .
cp -f ../../CUnit/Sources/Win/Win.h .
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/doc/headers'
make[3]: Nothing to be done for `install-exec-am'.
cp -f ../../CUnit/Headers/*.h .
cp -f ../../CUnit/Sources/Win/Win.h .
test -z "/mingw/doc/CUnit/headers" || /bin/mkdir -p "/mingw/doc/CUnit/headers"
 /bin/install -c -m 644 Automated.h Basic.h Console.h CUError.h CUnit.h CUnit_intl.h CUCurses.h MyMem.h TestDB.h TestRun.h Util.h Win.h '/mingw/doc/CUnit/headers'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/doc/headers'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/doc/headers'
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/doc'
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/doc'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/mingw/doc/CUnit" || /bin/mkdir -p "/mingw/doc/CUnit"
 /bin/install -c -m 644 CUnit_doc.css error_handling.html fdl.html index.html introduction.html managing_tests.html running_tests.html test_registry.html writing_tests.html '/mingw/doc/CUnit'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/doc'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/doc'
make[1]: Leaving directory `/d/cunit/CUnit-2.1-2/doc'
Making install in Man
make[1]: Entering directory `/d/cunit/CUnit-2.1-2/Man'
Making install in man3
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/Man/man3'
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/Man/man3'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/mingw/share/man/man3" || /bin/mkdir -p "/mingw/share/man/man3"
 /bin/install -c -m 644 CUnit.3 '/mingw/share/man/man3'
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/Man/man3'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/Man/man3'
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/Man'
make[3]: Entering directory `/d/cunit/CUnit-2.1-2/Man'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/d/cunit/CUnit-2.1-2/Man'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/Man'
make[1]: Leaving directory `/d/cunit/CUnit-2.1-2/Man'
Making install in Share
make[1]: Entering directory `/d/cunit/CUnit-2.1-2/Share'
make[2]: Entering directory `/d/cunit/CUnit-2.1-2/Share'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/mingw/share/CUnit" || /bin/mkdir -p "/mingw/share/CUnit"
 /bin/install -c -m 644 CUnit-List.dtd CUnit-List.xsl CUnit-Run.dtd CUnit-Run.xsl Memory-Dump.dtd Memory-Dump.xsl '/mingw/share/CUnit'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2/Share'
make[1]: Leaving directory `/d/cunit/CUnit-2.1-2/Share'
make[1]: Entering directory `/d/cunit/CUnit-2.1-2'
make[2]: Entering directory `/d/cunit/CUnit-2.1-2'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/mingw/lib/pkgconfig" || /bin/mkdir -p "/mingw/lib/pkgconfig"
 /bin/install -c -m 644 cunit.pc '/mingw/lib/pkgconfig'
make[2]: Leaving directory `/d/cunit/CUnit-2.1-2'
make[1]: Leaving directory `/d/cunit/CUnit-2.1-2'

eclipseを起動します。

「ウィンドウ」→「設定」→「C/C++」→「デバッグ」→「ソース・ルックアップパス」を開きます。

「追加」ボタンをクリックし、「パス・マッピング」を選択し「OK」クリック後、「名前」に「minDrive」を設定します。さらに、「追加」ボタンをクリックし、「コンパイル・パス」に「\インストールしたドライブ」を、「ローカル・ファイル・システム・パス」に「インストールしたドライブ:\」を設定し、「OK」クリック。

テスト用に新規プロジェクトを作成します。「ファイル」→「新規」→「Cプロジェクト」を選択します。「名前」は適当に設定して、「ツールチェーン」は「MinGW GCC」を選択し、「完了」ボタンをクリックします。

eclipseでプロジェクトのプロパティを表示します(トップディレクトリを選択してALT+ENTERなど)。「C/C++ ビルド」を選択し、さらに配下の「設定」を選択します。「ツール設定」タブの「MinGW C Linker」を選択し、さらに「ライブラリー」を選択します。

ライブラリーの新規選択ボタンをクリックし、「ライブラリー」に「cunit」を設定し、「OK」をクリック。「ライブラリー検索パス」も同様に新規ボタンをクリックし、「ディレクトリ」に「/usr/local/lib」を設定し、「OK」をクリック。最後にもう一度「OK」をクリック。

ここで1回Buildすると、「ウィンドウ」→「設定」→「C/C++」→「デバッグ」配下にGDBがでてくるはず。で、「GDBデバッガー」に「ドライブ:/mingw/bin/gdb.exe」を設定する。

実際に、F11押下で動作させて、最初の行でBreakしてHelloWorld等想定の動作になることを確認します。

CUnitを使ってみます。

mingwTest.c

#include <stdio.h>
#include <stdlib.h>
#include <Cunit/Cunit.h>
#include <CUnit/CUError.h>
#include <CUnit/TestDB.h>
#include <CUnit/TestRun.h>
#include <CUnit/Automated.h>
#include <CUnit/Basic.h>
#include <CUnit/Console.h>


int testSub1(int no) {
 return no - 1;
}
int testSub2(int value) {
 return value - 1;
}

void test1(void) {
 CU_ASSERT( testSub1(10) == 9);
}

void test2(void) {
 if (testSub2(10) == 8) {

}
 else {
 CU_FAIL("想定した値と異なります。")
 }
}

int main() {
 printf("Start Test\n");

CU_pSuite suite1;

CU_initialize_registry(); // CUnit初期化
 suite1 = CU_add_suite("suite",NULL,NULL);
 CU_add_test(suite1, "test001", test1); //テストの追加
 CU_add_test(suite1, "test002", test2); //テストの追加
 CU_console_run_tests(); //テスト実行
 CU_cleanup_registry(); //お掃除

return EXIT_SUCCESS;
}

Build後、CTRL+F11でeclipseのコンソール上にこんな感じで表示されます。(R)unで実行です。

Start Test
 CUnit - A Unit testing framework for C - Version 2.1-2
 http://cunit.sourceforge.net/
(R)un (S)elect (L)ist (A)ctivate (F)ailures (O)ptions (H)elp (Q)uit
Enter command: =thread-exited,id="2",group-id="i1"
r
Running Suite : suite
 Running Test : test001
 Running Test : test002
Run Summary: Type Total Ran Passed Failed Inactive
 suites 1 1 n/a 0 0
 tests 2 2 1 1 0
 asserts 2 2 1 1 n/a
Elapsed time = 0.002 seconds
(R)un (S)elect (L)ist (A)ctivate (F)ailures (O)ptions (H)elp (Q)uit

上へ 準備 PHP C