cc calls cl twice when used from msvc

Help
Ben Hymers
2008-04-01
2013-04-24
  • Ben Hymers
    Ben Hymers
    2008-04-01

    Hi, I have a C++ project building with ant, and I've just set up a msvc makefile project to start ant on a build. It's exactly the same as building from the command line, except there are these extra lines generated:

    1>Microsoft (R) Incremental Linker Version 8.00.50727.762
    1>Copyright (C) Microsoft Corporation.  All rights reserved.
    1>LINK : warning LNK4001: no object files specified; libraries used
    1>LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
    1>LINK : fatal error LNK1159: no output file specified
    1>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
    1>Copyright (C) Microsoft Corporation.  All rights reserved.
    1>cl : Command line warning D9002 : ignoring unknown option '/bogus'
    1>cl : Command line error D8003 : missing source filename

    It seems that CC calls cl and link an extra time before actually doing any compilation or linking, and this is generating errors that get put in my msvc task list, and I don't like errors! I've only got one <cc/> element in build.xml, with no <compiler/> or <linker/> nested elements (same problem if they are, though). Has anyone else experienced this? If so, how can you make this stop?

     
    • Curt Arnold
      Curt Arnold
      2008-04-01

      The preliminary calls to cl and link are to determine what version of cl and link are being used so it can be compared against the version info that is stored in the history.  Unfortunately, the Microsoft tools do not (or at least did not) have a command switch to output the version info and then exit.  "cl /?" will not generate an error, but it will paginate the output which will cause cpptasks to stall, so the workaround was to use "cl /bogus" which causes the version to be output before the unrecognized option caused the compiler to exit.

      When cpptasks was written it was very common to have multiple versions of a single compiler around and you did not want to end up with a build directory with a object files from a mix of compilers.  If you switch what compiler was on the path between invocations.

      If you are willing to hack cpptasks, the easiest way to suppress the version check is to modify AbstractProcessor.getIndentifer(String[], String) so that it just returns the fallback parameter instead of invoking the command.