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

From NAMIC Wiki
Jump to: navigation, search
m (Text replacement - "http://www.slicer.org/slicerWiki/index.php/" to "https://www.slicer.org/wiki/")
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
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.
+
<big>'''Note:''' We are migrating this content to the slicer.org domain - <font color="orange">The newer page is [https://www.slicer.org/wiki/Slicer3:Module_Link_Setup_for_Windows  here]</font></big>
 
 
== 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:
 
 
 
<pre>
 
#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
 
</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:
 
<pre>
 
CONFIGURE_FILE(
 
  ${LIBRARYNAME_SOURCE_DIR}/vtkLibraryNameConfigure.h.in
 
  ${LIBRARYNAME_BINARY_DIR}/vtkLibraryNameConfigure.h
 
)
 
</pre>
 
 
 
==I still get linker errors==
 
If you still get the linker errors lnk2001 or lnk 2019 make sure that you declared the copy constructor and the assignment operator:
 
<pre>
 
vtkMyClass(const vtkMyClass&);
 
void operator=(const vtkMyClass&);
 
</pre>
 

Latest revision as of 18:02, 10 July 2017

Home < Slicer3:Module Link Setup for Windows

Note: We are migrating this content to the slicer.org domain - The newer page is here