Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 830
Tim Finer Avatar asked Jul 05 '12 15:07

Tim Finer


People also ask

How do I compile without linking GCC?

The -c option in the command means compile (but don't link). The result of this will be .o (object) files. Try the command without the -c , it should link and create your snmpy executable. Save this answer.

Can I use Visual Studio to compile C?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.

What does Visual Studio compile with?

open a loose folder of source files with no project file. Visual Studio will use heuristics to build the files. This is an easy way to compile and run small console applications.

How do I compile only Visual Studio?

Ctrl+F7 will compile only the active source file.


1 Answers

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.

like image 67
Ben Voigt Avatar answered Oct 22 '22 07:10

Ben Voigt