.NET assemblies used for invoking common executable tools in a separate process.
Tests are not being ran automatically because of special environmental requirements.
- API for compiling code using the Visual Studio C/C++ Optimizing Compile;
- Visual Studio 2010 - 2013 (for VisualStudioCommonTools);
- NVidia CUDA Toolkit (for NvidiaToolkit);
- This project does not contain a compiler. It invokes the VC compiler that is present on the system where VisualStudioTools assembly is called.
To install External-Invocations, run the following command in the Package Manager Console
PM> Install-Package Karadzhov.ExternalInvocations
- Make sure your project references the Karadzhov.ExternalInvocations.VisualStudioCommonTools assembly;
- Add a using statement for this namespace: Karadzhov.ExternalInvocations.VisualStudioCommonTools;
- Create a new instance of the COptimizingCompiler class;
- You can pass an argument to the constructor specifying the target platform. Amd64 and X86 are supported;
- If you use the parameterless constructor the COptimizingCompiler class will target the architecture the current process is running in;
- Create an instance of the CCompileArguments class;
- Use the Files property to pass file paths to the compiler (CL Filename Syntax);
- Choose level of optimization by setting the Optimizations property (available options are None and MaximumOptimizations);
- Set IsDll to true if you want the compiler to produce a dynamic library;
- The Output property to instruct the linker about the output file name (/OUT (Output File Name));
- Call COptimizingCompiler.Compile with the arguments you have created to invoke the compiler;
- There is no return value. Karadzhov.ExternalInvocations.VisualStudioCommonTools.CompilationException is thrown if the compilation was not successful.
This sample compiles a C source file into a DLL using C#.
var compiler = new COptimizingCompiler();
var arguments = new CCompileArguments();
arguments.Files.Add(Path.Combine(samplesPath, "sum.c"));
arguments.Optimizations = CompileOptimization.MaximumOptimization;
arguments.IsDll = true;
arguments.Output = "bin\\sum.dll";
compiler.Compile(arguments);
- Make sure your project references the Karadzhov.ExternalInvocations.NvidiaToolkit assembly;
- Add a using statement for this namespace: Karadzhov.ExternalInvocations.NvidiaToolkit;
- Create a new instance of the CudaCompiler class;
- Create a new instance of the CudaCompileArguments class;
- This class inherits from CCompileArguments. Refer the instructions for the VC compiler for details;
- Set the ComputeCapability property to specify the target GPU compute capability;
- Set the TargetProcessorArchitecture to specify whether 32 or 64 bit binary should be compiled;
- Call CudaCompiler.Compile with the arguments you have created to invoke the compiler;
- There is no return value. Karadzhov.ExternalInvocations.VisualStudioCommonTools.CompilationException is thrown if the compilation was not successful.
Now that you are compiling DLLs on the fly you can also call them right away by using the Dynamic-Libraries project: Dynamic-Libraries