Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

VS2015 How to Prevent Linking

chauvjo
Novice
376 Views

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

Thanks...

0 Kudos
6 Replies
Kevin_D_Intel
Employee
376 Views

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.

0 Kudos
Steven_L_Intel1
Employee
376 Views

Create your project as a "Static Library" project rather than Console Application, etc.

0 Kudos
Kevin_D_Intel
Employee
376 Views

Actually, it turns out this isn't behaving for C++ projects either so I may have the wrong impression of this Build Only option. I'll discuss this w/Development.

0 Kudos
Steven_L_Intel1
Employee
376 Views

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.

0 Kudos
Kevin_D_Intel
Employee
376 Views

Steve is correct. Development confirmed that for Build Only, if the build normally includes compilation and linking, then both are performed.

0 Kudos
mecej4
Honored Contributor III
376 Views

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.

0 Kudos
Reply