Difference between revisions of "Slicer3:Module Link Setup for Windows"

From NAMIC Wiki
Jump to: navigation, search
Line 12: Line 12:
 
vtkLibraryNameConfigure.h.in -- just copy and rename an example one.
 
vtkLibraryNameConfigure.h.in -- just copy and rename an example one.
  
vtkLibraryName.h -- copy and rename example one and have it include vtkLibraryNameWind32Header.h (note that this .h file will be in your build directory and is made from the .h.in file above).
+
vtkLibraryName.h -- copy and rename example one and have it include vtkLibraryNameWin32Header.h (note that this .h file will be in your build directory and is made from the .h.in file above).
  
 
vtkLibraryNameWin32Header.h -- make the following changes:
 
vtkLibraryNameWin32Header.h -- make the following changes:
Line 34: Line 34:
 
#endif
 
#endif
 
</pre>
 
</pre>
 
  
 
== In your code ==
 
== In your code ==

Revision as of 17:14, 19 September 2007

Home < Slicer3:Module Link Setup for Windows

When making a new library or module for Slicer3 you need to carefully set things up so for building. Best thing to do is copy an existing directory that does something similar to what you have in mind and then change things to match your module setup.

Definitions

LibraryName is the first argument to ADD_LIBRARY in CMakeLists for your directory.

LIRBARYNAME is the argument to PROJECT() at the top of the CMakeLists

Files to Change/Create

vtkLibraryNameConfigure.h.in -- just copy and rename an example one.

vtkLibraryName.h -- copy and rename example one and have it include vtkLibraryNameWin32Header.h (note that this .h file will be in your build directory and is made from the .h.in file above).

vtkLibraryNameWin32Header.h -- make the following changes:

#ifndef __vtkLibraryNameWin32Header_h
#define __vtkLibraryNameWin32Header_h

#include <vtkLibraryNameConfigure.h>

#if defined(WIN32) && !defined(VTKSLICER_STATIC)
#if defined(LibraryName_EXPORTS)
#define VTK_LIBRARYNAME_EXPORT __declspec( dllexport ) 
#else
#define VTK_LIBRARYNAME_EXPORT __declspec( dllimport ) 
#endif
#else
#define VTK_LIBRARYNAME_EXPORT 
#endif

#endif

In your code

In the .h files for your classes:

#include "vtkLibraryName.h"

Declare your classes as:

class VTK_LIBRARYNAME_EXPORT vtkMyClass : public vtkMySuperClass


CMakeLists.txt should contain:

CONFIGURE_FILE(
  ${LIBRARYNAME_SOURCE_DIR}/vtkLibraryNameConfigure.h.in 
  ${LIBRARYNAME_BINARY_DIR}/vtkLibraryNameConfigure.h
)