I usually try to work in Python when I'm making a Maya plugin, but the next few I have planned require some serious computational efficiency, so they'll have to be in C++. Compiling a Maya plugin in Visual Studio is relatively straightforward. Maya provides a Visual Studio "Solution Wizard" that basically does all of that for you. However, I also am going to be using CUDA for some of the plugins, which complicates the process a little bit, but I'll get to that in a minute.
First, we need to get a basic plugin in Visual Studio working. Hopefully you have admin privileges on the computer you are working on, as that makes this process a bit easier. Go to "C:\Program Files\Autodesk\Maya201x\devkit\pluginwizard" and follow the instructions in the MayaWizardReadme.txt
Afterwards, go to Project->Build Customization and check the CUDA box. In simple terms, this makes sure your .cu files are compiled. You also need to add
$(CudaToolkitLibDir);
to both 'Additional Include Directories' in C/C++->General and 'Additional Library Directories' in Linker->General.
And then add
cudart.lib
to Linker->Input.
Now go about your business with CUDA and set up some kernels. But, if you try to compile, you may get some errors that look like this:
1>C:\Program Files\Autodesk\Maya2014\include\maya/MTypes.h(269): error C2373: 'short2' : redefinition; different type modifiers
1> c:\program files\nvidia gpu computing toolkit\cuda\v5.5\include\vector_types.h(148) : see declaration of 'short2'
Which is annoying. The Maya api and CUDA both define a bunch of types with #defines that have the same name. To get around this, after you include your CUDA files, but before you include your Maya api files, add some more #defines that rename the cuda types to something else. For instance,
#define short2 CUDA_short2
#define short3 CUDA_short3
#define long2 CUDA_long2
#define long3 CUDA_long3
#define int2 CUDA_int2
#define int3 CUDA_int3
#define float2 CUDA_float2
#define float3 CUDA_float3
#define double2 CUDA_double2
#define double3 CUDA_double3
#define double4 CUDA_double4
And now you should be all set.