# Plugin¶

An Ocean plugin is a dynamic linked library (DLL) containing several new Ocean object types such as:

To make a plugin, you need to create a .cpp file usually named pluginmain.cpp which includes the header <oceansdk/pluginmain.h> from the SDK.

This header declares an OceanPlugin class which defines many convenience functions and declares an init() function that you need to define in your pluginmain.cpp file. It makes plugin creation easier, as the base plugin interface OOcean::Sdk::DLLInterface declared in header <oceansdk/sdkcommon.h> is more complex.

Warning

The pluginmain.cpp header must be included only once in your project in order to avoid errors related to symbols defined multiple times. The symbols getOceanSdkDLLInterface and OceanPlugin::instance are defined in the header.

Once you have included <oceansdk/pluginmain.h>, you need to define OceanPlugin::init to register the node types that you have created using registerBsdf, registerEnvironment, registerEnvironment, registerFilterShader, registerScalarShader and registerNormalShader template functions.

## Code example¶

In our example, pluginmain.cpp will look like:

#include <oceansdk/pluginmain.h>
#include "testenvironment.h"
#include "test2environment.h"
#include "testbsdf.h"
#include "test2bsdf.h"

void OceanPlugin::init()
{
registerEnvironment<TestEnvironment>();
registerEnvironment<Test2Environment>();
registerBsdf<TestBsdf>();
registerBsdf<Test2Bsdf>();

}


To compile it, you need to include all files created in other plugin examples (see below) and execute in the SDK toolchain environment:

> g++ -shared -o sdktest.dll *.cpp


The compiled DLL must be copied to one of the Ocean plugins folder, that you may find in the Folders tab of the Preferences