Compiling Houdini plugins on Windows

compiling houdini plugin on windows using HDK
compiling houdini plugin on windows using HDK

This is a quick introduction to compiling Houdini plugins on Windows . There a couple of prerequisites you need to suffice before you can compile your first plugin. Once you set your environment you can jump start from various plugin examples that come installed with Houdini.

There are 2 ways to compile on Windows and Linux, as explained below. Most of the process is similar on both OS’s but compiling utilities, installation paths, env paths will differ. I will mainly explain the process on Windows.

  1. Hcustom – hcustom is sesi’s command line utility to compile C code. This is good if your plugin is a single C++ source file.
  2. CMake – It’s a system which can create project files for various build systems and IDE’s like Ninja, Visual Studio etc. It can compile source code, create libraries, generate wrappers and build executables. In our case, it will generate Visual Studio code from makefiles provided by sesi, which will eventually compile a Houdini plugin. CMake uses special files call Makefile (or makefile) which contains shell commands to carry out various tasks. You can either use the makefiles provided by sesi or can create your own  as explained on this page:  hdk_intro to compiling
SETTING YOUR COMPILE ENVIRONMENT

To start building plugins you will need at least these 3 tools, Houdini, Visual Studio and CMake.

  1. Download and install Microsoft Visual Studio 2015 (vc14 Microsoft Visual C++ 2015) if you are compiling plugins for Houdini 16.5 .  Ideally, you should match your MSVC version to that of Houdini’s MSVS version. When you download Houdini, MSVC version is mentioned in the file name. For eg: houdini-x.y.zzz-win64-vc14.exe
  2. Install CMake from http://www.cmake.org .
    CMake will generate MSVC project files which will eventually be used to build the plugin dll on windows.
  3. On Windows, set MSVCDir env variable through sesi’s “command line tools”. This can be accessed from Start menu in side effects folder and resides in Houdini x.y.zzz\bin.
    set MSVCDir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
  4. Create an env var “CMAKE_PREFIX_PATH” through System > Advanced system settings > Environment Variables button.
    CMAKE_PREFIX_PATH = C:\Program Files\Side Effects Software\Houdini x.y.zzz\toolkit\cmake

    Make sure you have $HFS set in your env variables and if not create it

    HFS = C:\Program Files\Side Effects Software\Houdini x.y.zzz\

    and you also have this in your system “path” env variable, if not append it

    C:\Program Files\Side Effects Software\Houdini x.y.zzz\bin\
COMPILING YOUR FIRST PLUGIN – SOP STAR

The easiest plugin that you can build and load in Houdini can be SOP_Star which comes installed with Houdini samples in the following location:

C:\Program Files\Side Effects Software\Houdini x.y.zzz\toolkit\samples\SOP\SOP_Star

Before doing anything, I would suggest making a copy of the whole samples folder so you don’t pollute the source folder.

  1. Open command shell and cd into the directory where you copied the samples folder. For e.g. :
    cd D:\work\houdini\HDK\samples\SOP\SOP_Star
  2. Now run the following command in the command window :
    cmake -G "Visual Studio 14 Win64"

    SOP_Star folder should have a file CMakeLists.txt which will build VC14 project files. These files will actually build the plugin. Till now we had just prepped the build environment and created relevant project files. If everything went fine you should see a message similar to this:

    -- Selecting Windows SDK version  to target Windows 10.0.17134.
    -- The C compiler identification is MSVC 19.0.24215.1
    The relaxed arteries extend and get filled with more blood.  order viagra online It is a short inhibitor exclusively created to deal with the problem sooner rather than later," Boone said."Am I viagra prescription  going to recover well enough to play baseball again? Probably. The sexual arousal or stimulation assist the ED patients get the results sooner than the  viagra cialis levitra men taking Kamagra without stimulation. Many men with less education are likely to experience the following benefits: A great state of relaxation in social situations Lesser anxiety Increased confidence Feeling of being more attractive Happy and optimistic outlook Enhanced working relationships Pepped up sex life Increased sense of well-being Feeling of empowerment With these benefits, many women trying to find dating partners are now seeking pheromones as an option to attract the opposite. drscoinc.com lowest cost levitra -- The CXX compiler identification is MSVC 19.0.24215.1
    -- Check for working C compiler:C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
    -- Check for working C compiler:C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe --works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler:C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
    -- Check for working CXX compiler:C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe --works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/work/houdini/HDK/samples/SOP/SOP_Star
  3. Once CMake is done creating its files, you will see  VisualStudio’s  .sln file built in Sop_Star > HDK_Project.sln. Open this in Visual Studio and select Sop_Star in the solution explorer panel and goto Build menu and hit Build Sop_Star. (note: The file name HDK_Project is specified in CMakeLists.txt – project( HDK_Project )). The compiled plugin Sop_Star.dll will be placed in Documents/houdini16.x/dso folder.

Tadaaa!!! You have finally built your first Houdini plugin.

TACKLING PROTO.H ERROR

You may encounter this error while building SOP_Star plugin:
Cannot open include file: ‘SOP_Star.proto.h’: No such file or directory SOP_Star

SOP_Star.proto.h file is dynamically generated based on files in houdini/toolkit and one file in perticular in Python2.7libs, namely “generate_proto.py” which creates this file for you.

If your $HFS path (Houdini File System ) is not set in your system environments, cmake will not be able to generate .proto.h file for you.

One quick and dirty solution is to add the toolkit path to Additional #Using Directories path in Visual Studio Project settings.

You can add this path by opening General project settings:

Projects Menu > SOP_Star properties > C/C++ > General

And the correct way to do this is to add the $HFS to your system environments, either manually or by sourcing this file through your command prompt.

C:\Program Files\Side Effects Software\Houdini x.y.zzz\houdini_setup

 

Thats it! Enjoy plugging!!!


Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.