Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use external build system for Visual C++ 2013 project?

Is it possible to use an external build system for VC++ 2013? I want Visual Studio do nothing but build by invoking my build tools.

I am thinking about something like this:

  • Put all build command in batches.
  • Invoke a project-level build batch by right clicking the project and choose build.
  • Invoke the a solution-level build batch by right clicking the solution and choose build.

    Is there some walk-through tutorial? I searched a lot but no luck.

ADD 1 - Some progress...

After briefly reading about the MSBuild process, I tried as below.

First, I edit the *.vcxproj project file. I change the DefaultTargets from Build to MyTarget.

<Project DefaultTargets="MyTarget" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Then I add a new target named MyTarget:

  <Target Name="MyTarget">
    <Message Text="Hello, Bitch!" />
  </Target>

I hope this can bypass the VS2013 built-in built process and only carry out my own batch.

It works well on command prompt:

enter image description here

But in Visual Studio, when I right click the project and choose build command, it gives me a lot of link errors.

How to avoid these link errors? Since my batch can take care of all the build process, I don't need Visual Studio to do the link for me.

ADD 2

It seems these link errors show up because I include the *.c files with the ClCompile tag as below.

<ItemGroup>
   <ClCompile Include="z:\MyProject1\source1.c" />
<ItemGroup>

Since I don't want VS2013 to invoke the compiler, I change it to <ClInclude> tag, the link errors disappeared, but the symbol resolution is not working... Seems I shouldn't change the tag.

ADD 3

Here's another way to compile without linking.

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

Seems it doesn't have the symbol resolution issue. But I still cannot invoke an external batch by click build/rebuild/clean.

like image 672
smwikipedia Avatar asked Oct 26 '15 02:10

smwikipedia


People also ask

How do I run a build in Visual Studio?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.

What build system does Visual Studio use?

Visual Studio will use heuristics to build the files. This is an easy way to compile and run small console applications.

How do I run a Makefile in Windows Visual Studio?

From the Visual Studio start page, type "makefile" in the New Project search box. Or, in the New Project dialog box, expand Visual C++ > General (Visual Studio 2015) or Other (Visual Studio 2017) and then select Makefile Project in the Templates pane to open the project wizard.


1 Answers

You might want to look into Visual Studio's makefile projects (in the Visual C++/General project templates category).

You get to specify what commands to execute for each type of build (clean, build, rebuild). The command can invoke a make, run a batch file, or invoke some other build tool. It just executes a command. The commands can contain various macros that VS provides (similar to environment variables) so the command can be parametrized for things like making a target directory based on the solution or project name or type (debug vs. release).

like image 57
Michael Burr Avatar answered Sep 28 '22 09:09

Michael Burr