PDA

View Full Version : Compiling a plug-in with Visual Studio 2005



ShawnStovall
08-28-2008, 05:49 PM
1.To compile a plug-in with Visual Studio start a new Win32 project and make it an empty DLL:

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK1.png

2.Add your source files as well as servmain.c, shutdown.c, startup.c, and username.c(these can be found in [Drive:]Program Files\[Appropriate LightWave directory]\SDK\source\):

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK2.png

3.To add the LightWave include directory you can go to Tools->Options which will open up the Options dialog and from here expand the "Projects and Solutions" tree and then click on the "VC++ Directories" branch. From here change the "Show directories for:" pop-up menu to "Include files":

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK5.png

4.Then you click the new line button and enter the directory for the LightWave include files or you can browse for it, now you won't have to worry about the include directories unless you reinstall Visual Studio or clear the include directories:

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK6.png

5.Now go to Project->Properties and this will open the project properties page. The first thing you need to do here is change the configuration type to "All Configurations":

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK3.png

6.From here expand the C/C++ tree and click on the "Preprocessor" branch. Add _X86_ and _MSWIN to the "Preprocessor Definitions" field(separated by a semicolon):

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK4.png

7.Then you click on the "Advanced" branch and change the "Compile As" field to "Compile as C Code (/TC)". NOTE:If you want to compile your source as C++ code leave this at its default value, plus you have to add some additional code in your source not covered by the SDK, there are a couple of good tutorial on the web that cover this though:

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK7.png

8.This step is not necessary as LightWave can use a .dll file just as well as a .p file, but just for conformity I change this anyway. Expand the "Linker" tree and click on "General". You can change the extension of the file in the "Output File" field to .p to get the compiler to save the DLL with a .p extension:

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK8.png

9.If you decided not to do the last step go ahead and expand the "Linker" tree now. Click on the "Input" branch and type or paste the path to the serv.def file which can be found in the LightWave source directory in the "Module Definition File" field:

http://i486.photobucket.com/albums/rr229/ShawnStovall/visstudioLWSDK9.png

After this just click "Apply" and you're ready to compile!

creacon
08-31-2008, 03:01 PM
great,

thanks to this simple explanation I got my first plugin compiled in 1 hour.
I did it in VS2008 and it works in exactly the same way.

creacon

jeremyhardin
09-01-2008, 10:25 AM
holy **** that's brilliant. very cool Shawn.

COBRASoft
09-01-2008, 01:57 PM
Now that's a handy tutorial :)

Great work :thumbsup:

ShawnStovall
09-01-2008, 02:32 PM
thanks :)

Celshader
09-01-2008, 03:41 PM
Thank you for taking the time to write this post, Shawn. I'm more afraid of compiler settings than I am of writing C code, so this information helps me a lot. :)

ShawnStovall
09-01-2008, 03:46 PM
Thank you for taking the time to write this post, Shawn. I'm more afraid of compiler settings than I am of writing C code, so this information helps me a lot. :)

heh, I didn't get into the SDK for months because of the compiler options. lol

falogfx
11-24-2011, 11:03 AM
Sorry for digging up an old thread but I really need to say thank you for this tutorial!

I've been trying for too many hours now to get the box1 sample to compile in Visual C++ 2010 Express, and with some efforts due to the different GUI in 2010 I finally succeeded to compile and run my very first plugin.

I'm totally a beginner in plugin development and haven't got much experience in C/C++ either, although I've been writing some LScripts and done quite a lot of programming in VB, php, javascript and such.

Now, just give me a couple of months and I should be able to make a load of boxes :)

Thanks again!