Problems with msvc and mingw g++

  • Daff

    Daff - 2008-04-04


    I'm new to ant and want to use it with cpptasks for a multi plattform and multi language project (C++ and Java using JNI) on Unix and Windows but it doesn't work with the msvc compiler (Visual Studio 2005).
    Using mingw also leads to an error message for c++ source code because it always seems to use the c and not the c++ compiler.

    My current build.xml testfile

    <project name="hello-world" default="compile-msvc">
        <property file=""/>
        <!-- Load Ant tasks and types for cpp compilers from cpptasks.jar (in current directory) -->
        <taskdef resource="cpptasks.tasks">
                <pathelement location="cpptasks.jar"/>
        <taskdef resource="cpptasks.types">
                <pathelement location="cpptasks.jar"/>
        <target name="compile-msvc">
            <cc outfile="test-msvc.exe" name="msvc">
               <fileset dir="." includes="main.cpp" />
        <target name="compile-gcc">
            <cc outfile="test-gcc.exe" name="g++">
               <fileset dir="." includes="main.cpp" />

    ant compile-msvc

    always leads to

    Total time: 1 second
    F:\build>ant compile-msvc
    Buildfile: build.xml

           [cc] 1 total files to be compiled.

    F:\build\build.xml:16: cl failed with return code -1073741515

    Total time: 1 second

    and compile-gcc results in some linker errors from the gnu c linker for c++ files (but works with c source).
    Is there a way to view the compiler and linker command lines?


    • Daff

      Daff - 2008-04-09

      Hm, should have tried this batch file before running ant:
      echo %VCINSTALLDIR%

      After that it works.
      Strange thing is, that an exec from within the build skript doesn't set the environment variables for ant:

      <target name="init_win32" if="is_win32">
          <property environment="env" />
          <property name="compiler" value="msvc" />
          <property name="vsvars32" value="${env.VS80COMNTOOLS}vsvars32.bat" />
          <echo>Loading Visual Studio environment variables (from ${vsvars32})</echo>       
          <exec executable="${vsvars32}" />

      • David Haney

        David Haney - 2008-04-09

        The exec task spawns a child process and that child process cannot affect the environment of the parent (ant) process.

    • Daff

      Daff - 2008-04-10

      Thanks thats what I feared. Ok... think I have to write a batch file for windows which sets the environment and then calls ant.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks