Tim Finer
Tim Finer

Reputation: 585

Is it possible for Visual Studio C++ to compile objects without linking

I'm running VS 2010 SP1 and I have a special analysis configuration that runs once a week (because it takes a long time for the build server to analyze everything).

I'd like this configuration to run without bothering to link. If the analysis passes for all the code in a project, then I'd like the build to just continue on to the next project without linking.

I can't see a way to tell VS to just run the C++ compiler without linking. Does anyone know of a way to do this within an existing vcxproj?

[Edit] Clarification: I'd like this to work from within the IDE.

My next course of action is hand editing the vcxproj to see if I can't get rid of the link phase of building.

Upvotes: 9

Views: 5960

Answers (4)

szdrnja
szdrnja

Reputation: 324

Microsoft docs claim that this option is not available from within the development environment.

Upvotes: 0

Tim Finer
Tim Finer

Reputation: 585

OK, I wasn't completely specific in my question, what I should have asked is: "Can I run static code analysis on C++ projects without linking?".

The recent answer is "Yes, with VS 2017 use the msbuild property RunCodeAnalysisOnce=true".

Upvotes: 2

jdknight
jdknight

Reputation: 1839

Just in this situation; trying to build without linking when using the IDE.

To achieve this for my configuration, I've altered the configuration type of my application:

General -> Project Defaults -> Configuration Type

Specifically, changing from Application (.exe) to Static library (.lib). This will allow all your project(s) to build, but not require any linking to occur.

Upvotes: 3

Ben Voigt
Ben Voigt

Reputation: 283634

The C++ compiler cl.exe certainly can, that's the /c switch (compile only, don't link). Not sure about the msbuild system that the IDE uses and that works with .vcxproj files, though.

According to the documentation, this should work:

msbuild /target:Compile projectfile

or

msbuild /target:projectname:Compile solutionfile

You might also be interested in the /filelogger and /fileloggerparameters options, which let you capture build messages.

Upvotes: 4

Related Questions