top of page

Compiling a Lightwave 3D plugin in C programming language - The fastest way.

No matter what 3D software, it is always a struggle to find complete information on how to compile a plugin. It is more complicated when the 3D artist wants to write the plugin in C programming language. To code in C is necessary for more specific stuff, like creating nodes, or to make plugins that deals better with memory management, for example.

I've been trying to collect information for both Python and C language plugin writing for Lightwave 3D and I've found very little (almost nothing) information. The Python and SDK official documentation are old and not didactic in a friendly way. In this tutorial I show how a 3D artist can compile a C plugin for Lightwave 3D, with minimum setup.


Time to make our hands dirty. Below are the steps to make a .p file (which actually is a .dll file), i.e. a Lightwave 3D plugin written in C programming language:


  1. Download the MinGW-w64 for Windows.

Download MingGW-w64 on https://winlibs.com
Download MingGW-w64 on https://winlibs.com

Choose your version.
Choose your version.

2. Extract the file to a folder of your choice. In my case, I extract it in my root folder C:/.


The file was extracted to C:/mingw64
The file was extracted to C:/mingw64

3. Now we have to put the mingw64 folder executable files in the system path.


Open up the System environment variables inside the Control Panel.
Open up the System environment variables inside the Control Panel.

Click on Environment Variables button.
Click on Environment Variables button.


Under System Variables, edit the Path variable.
Under System Variables, edit the Path variable.

Click on NEW and type the mingw64 binaries folder path.
Click on NEW and type the mingw64 binaries folder path. Then click on OK.

4. It is necessary to unzip the Lightwave 3D SDK, which is located on the Lightwave 3D installation folder.


Locate the SDK folder inside the Lightwave 3D installation folder.
Locate the SDK folder inside the Lightwave 3D installation folder.

Extract the lwsdk2020.0.zip to a folder of your choice.
Extract the lwsdk2020.0.zip to a folder of your choice.

5. Go to where you put the SDK files and copy all content inside the include folder to the homonym folder inside the mingw64 directory.


Copy the content of the SDK include folder...
Copy the content of the SDK include folder...

... and put it inside the include folder of the mingw64 directory.
... and put it inside the include folder of the mingw64 directory.

6. Go to the Lightwave SDK source folder.


In my case, I put the SDK inside my Documents folder.
In my case, I put the SDK inside my Documents folder.

Open the command line interface by typing "cmd" on the folder address tab and pressing ENTER.
Open the command line interface by typing "cmd" on the folder address tab and pressing ENTER.

The command line interface environment. I typed the "dir" command and ENTER to list the directory content.
The command line interface environment. I typed the "dir" command and ENTER to list the directory content.

7. It is time to compile the library sources. You do this by typing the following command: gcc -c -D_MSWIN -D_X64_ -O6 -I$(LWSDK_INCL) servmain.c servdesc.c username.c startup.c shutdown.c

And then, press ENTER.



The object files ( *.o) will be generated.
The object files ( *.o) will be generated.

8. Now we have to assemble the library. For this, we type ar r libserver.a servdesc.o username.o startup.o shutdown.o

And then, ENTER.



The file libserver.a was created.
The file libserver.a was created.

9. Now it is the final step: the creation of the plugin. I created a folder named box01 inside the source directory for organization purposes.


mkdir command to create a folder.
mkdir command to create a folder. In this case, mkdir box01, to create a folder called "box01".

Then, I copied the sample code box.c from the SDK Modeler samples folder to the box01 directory.

Here it is the content of the box.c source code. Note that "LWSDK_Tutorial_Box1" will be the name of the plugin inside Lightwave.
Here it is the content of the box.c source code. Note that "LWSDK_Tutorial_Box1" will be the name of the plugin inside Lightwave.

Inside the box01 folder, Type gcc -c -D_MSWIN -D_X64_ -O6 -I$(LWSDK_INCL) box.c and ENTER to compile the source code.



The box.o object file was created.
The box.o object file was created.

The last step is to link the object file to the SDK library and generate the box.p file, our plugin. Fpr this, you type dllwrap -o box.p --export-all --dllname box.p box.o ../servmain.o ../libserver.a and ENTER. Note the (../) before servmain.o and libserver.a. This is necessary because we are inside the box01 folder located under the source folder. Servmain.o and libserver.a are inside the source folder, exactly one level up. The (../) is exactly to access the files in the folder above.



There were some warnings. Nothing to worry about.
There were some warnings. Nothing to worry about.

Our plugin box.p is ready for use.
Our plugin box.p is ready for use.

10. Loading the plugin in Lightwave 3D.


In the Utilities tab, go to the option "add plugin" to make our plugin available inside  Modeler.
In the Utilities tab, go to the option "add plugin" to make our plugin available inside Modeler.

The plugin was loaded. Note the name of the plugin inside Modeler.
The plugin was loaded. Note the name of the plugin inside Modeler.

I added the plugin in the interface.
I added the plugin in the interface.

Now, we click on the button and our plugin is fully functional.
Now, we click on the button and our plugin is fully functional.

11. What's next? The Lightwave SDK documentation has a lot of other examples. The Lightwave artist must read the SDK doc to get familiar with the Lightwave C plugin code nuances. To know Lscript would help a lot, have no doubt. This is the beginning of a long journey.



One last thing you should know:


Slick3d.art was selected as one of the Top 20 3D Art Blogs on the web by FeedSpot. It is a great victory to me. It is a huge effort in very hard times. Besides, Slick3d.art encompasses my love for design and writing that started in my teen years. I am very grateful for the recognition that was a total surprise. Click here to go to FeedSpot Top 20 list or click on the image down below.



And do not forget: Donation = Loving ❤

Help me to do more tutorials. Please, consider to make a donation if this content helped you.


You can click on the QR code image down below to open up the payment window or just scanned it :



Or you can use Paypal:


167 views0 comments