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

From NAMIC Wiki
Jump to: navigation, search
(New page: 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...)
 
Line 34: Line 34:
 
#endif
 
#endif
 
</pre>
 
</pre>
 +
 +
 +
== 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:
 
CMakeLists.txt should contain:

Revision as of 16:58, 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 vtkLibraryNameWind32Header.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
)