>ant -verbose Apache Ant version 1.7.1 compiled on June 27 2008 Buildfile: build.xml Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_13\jre Detected OS: Windows XP parsing buildfile C:\home\Ant_CppUnit\build.xml with URI = file:/C:/home/Ant_CppUnit/build.xml Project base dir set to: C:\home\Ant_CppUnit [antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found. Build sequence for target(s) `all' is [init, clean, compile, all] Complete build sequence is [init, clean, compile, all, compileonly, linkonly, test, ] init: [mkdir] Skipping C:\home\Ant_CppUnit\build because it already exists. [mkdir] Skipping C:\home\Ant_CppUnit\dist because it already exists. clean: [delete] Deleting directory C:\home\Ant_CppUnit\build [delete] Deleting C:\home\Ant_CppUnit\build\Counter.o [delete] Deleting C:\home\Ant_CppUnit\build\CounterTest.o [Delete] Deleting C:\home\Ant_CppUnit\build\history.xml [delete] Deleting C:\home\Ant_CppUnit\build\test.o [delete] Deleting directory C:\home\Ant_CppUnit\build [mkdir] Created dir: C:\home\Ant_CppUnit\build [delete] Deleting directory C:\home\Ant_CppUnit\dist [delete] Deleting C:\home\Ant_CppUnit\dist\history.xml [delete] Deleting directory C:\home\Ant_CppUnit\dist [mkdir] Created dir: C:\home\Ant_CppUnit\dist compile: [cc] 3 total files to be compiled. [cc] g++ -c -g C:\home\Ant_CppUnit\src\test.cpp C:\home\Ant_CppUnit\src\CounterTest.cpp C:\home\Ant_CppUnit\src\Counter.cpp [cc] Starting link [cc] gcc -g -o test ..\build\test.o ..\build\CounterTest.o ..\build\Counter.oC++ のソースを Ant でコンパイルを行おうとしていてもリンクエラーが発生することがある。その場合に -verbose オプションを付けて実行すると最後の行で gcc によりリンクを行おうとしていることが確認できる。
これにより手元の cygwin 環境には libstdc++ がインストールされていないことが判明したので、libstdc++ をインストール。
build.xml の該当箇所を以下のように修正し再度実行したところ無事にコンパイル・リンクを行うことができた。
<target name="compile" depends="init"> <cc outtype="executable" subsystem="console" outfile="${dist.dir}/test" objdir="${build.dir}" debug="true"> <compiler name="g++"> <fileset dir="${src.dir}" includes="*.cpp"/> </compiler> <linker name="gcc" libtool="true"> <libset libs="cppunit,stdc++"/> </linker> </cc> </target>
0 件のコメント:
コメントを投稿