In VS2015, how do I configure my project to prevent linking (i.e. only create object files)? I have tried using the /c option but VS2015 is still is giving linking errors:
fatal error LNK1120: 1 unresolved externals error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
For a single source file, under the Solution Explorer one can right-click and select Compile, or left-click on the source file to set the focus and then use Ctrl-F7.
For a project, under the Solution Explorer one can right-click on the Project, then under Project Only select Build Only, or via the Build menu pull-down do the same; however, this is not functioning as expected with Intel Fortran projects. I’m currently using our PSXE 2017 Fortran integrations (Version 17.0.0036.11 ) with MSVS and this build selection is both compiling and linking with a Fortran project. It behaves as expected with a C/C++ project, compiling the project only.
Unfortunately I could not find a work around.
Build Only works fine - but if your project is an executable (or DLL) project, it will link. That's why I suggested using a Static Library project when you have no main program.
Even for a static library project, the build process probably calls LIB.EXE as the last step, although this is unnecessary if no static library is desired. The extra time consumed, however, is probably small. Perhaps there has been little demand for an objects-only project and so there is no corresponding VS template for it.