Materials > Working with External Materials > How to Compile and Link an External Material Model

How to Compile and Link an External Material Model
To export functions from the DLL when using Microsoft Visual Studio to compile your library, you must declare the functions as __declspec(dllexport). Therefore, to write a source code that works across platforms, use the following #define pattern:
#ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
 
EXPORT <return_type> eval(<arguments>) { }
Compiling and Linking
To compile the function into a library, place it in a file (here called ext.c as an example) and proceed as follows depending on the platform:
See http://www.comsol.com/system-requirements for information about supported compiler versions.
-
Start Microsoft Visual Studio>Visual Studio Tools>Visual Studio x64 Win64 Command Prompt (2010) from the Windows Start menu.
-
cd to the directory that contains ext.c.
-
-
-
-
-
-
-
-
For other compilers, refer to the compiler’s documentation for instructions on how to compile and create a shared library.