<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Does this also require the newer CMAKE? I had 2.10.8 but I am not afraid to install a newer one (3.5.0?)
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Bradley Lowekamp [mailto:blowekamp@mail.nih.gov]
<br>
<b>Sent:</b> 23 March 2016 17:23<br>
<b>To:</b> Atwood, Robert (DLSLtd,RAL,SCI)<br>
<b>Cc:</b> matt.mccormick@kitware.com; insight-users@itk.org<br>
<b>Subject:</b> Re: [ITK-users] stand-alone lib -- ITKApps/ITKFilterLib -- Solved (maybe)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hello,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think there are some plan old C file too. I just add the following to the cmake command line:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:8.5pt">-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.5pt"><br>
<br>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.5pt">You could also add “-fPIC” to the CFLAGS too.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.5pt"><br>
<br>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:8.5pt">Brad<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Mar 23, 2016, at 1:04 PM, <<a href="mailto:Robert.Atwood@diamond.ac.uk">Robert.Atwood@diamond.ac.uk</a>> <<a href="mailto:Robert.Atwood@diamond.ac.uk">Robert.Atwood@diamond.ac.uk</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi, Matt<br>
I did that but it didn't work. Exactly the same error. See a little further back in the thread:<br>
<br>
That's where I lost patience with 'combinatorial trial and error approach' , I added -fPIC everywhere I could think of
<br>
The position-independent-code seems to be generated for all libs except a small selction of i/o libs ; gdcm* ,Nrrd , and a couple of others (trial-and-error)
<br>
<br>
If I don't include these in the final link, then the link is successful. All other libraries appear to have PIC generated.
<br>
<br>
But, the final library isn't usable. I wonder what these ones have in common?? Is there a 'glitch' in the makefile generation that omits -fPIC in these cases somehow?
<br>
<br>
<br>
libitkgdcmjpeg8-4.10.a<br>
libitkgdcmjpeg12-4.10.a<br>
libitkgdcmjpeg16-4.10.a<br>
libitkgdcmopenjpeg-4.10.a<br>
libitkgdcmuuid-4.10.a<br>
libITKEXPAT-4.10.a<br>
libITKniftiio-4.10.a<br>
libITKNrrdIO-4.10.a<br>
libitkhdf5-4.10.a<br>
libitksys-4.10.a<br>
<br>
(using system jpeg, tiff, zlib and png) <br>
<br>
Ironically , it's only .mhd I actually want to use and it is not on the problem list. But the io-objects need all these to be available just in case they get used, I suppose.
<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">I have tried some combinations of these options but, you know, it<br>
takes a while to rebuild ITK even though the computer is pretty good.<br>
BUILD_POSITION_DEPENDENT_CODE OFF (I don’t think this should be ON<br>
because that really wouldn’t work? )<br>
BUILD_SHARED_LIBS OFF (or ON)<br>
CMAKE_CXX_FLAGS -fPIC (or default)<br>
CMAKE_EXE_LINKER_FLAGS -fPIC (or default)<br>
CMAKE_STATIC_LINKER_FLAGS (should this be set too? )<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
Regards, Robert<br>
<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">-----Original Message-----<br>
From: Matt McCormick [<a href="mailto:matt.mccormick@kitware.com">mailto:matt.mccormick@kitware.com</a>]<br>
Sent: 23 March 2016 16:29<br>
To: Atwood, Robert (DLSLtd,RAL,SCI)<br>
Cc: Dženan Zukić; <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>
Subject: Re: [ITK-users] stand-alone lib -- ITKApps/ITKFilterLib -- Solved<br>
(maybe)<br>
<br>
Hi Robert,<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">/usr/bin/ld:<br>
/dls_sw/apps/itk/itk-master-static/lib/libitkgdcmjpeg8-4.10.a(jerror.c<br>
.o): relocation R_X86_64_32S against `.text' can not be used when<br>
making a shared object; recompile with -fPIC<o:p></o:p></p>
<p class="MsoNormal"><br>
This means that "-fPIC" should be added to the CMAKE_CXX_FLAGS for ITK.<br>
<br>
HTH,<br>
Matt<br>
<br>
On Wed, Mar 23, 2016 at 11:58 AM, <<a href="mailto:Robert.Atwood@diamond.ac.uk">Robert.Atwood@diamond.ac.uk</a>><br>
wrote:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">Hi, Dženan, and List :<br>
<br>
<br>
<br>
Thanks for the tips, but, building the executable by pointing to the<br>
itk-build folder for linking is exactly what I did not want to do. I<br>
want the compiled instances of the specific templated objects to be<br>
put into a stand-alone library that could then be linked , in an<br>
environment where the ITK build directory may not be available, and<br>
within a project that’s not using cmake (yet? J ) just for a small<br>
single-data-type-specific filter chain that would be a bit nontrivial to just re-<o:p></o:p></p>
<p class="MsoNormal">implement myself!<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
<br>
I had some success with the following, for the example ITKFilterLib:<br>
<br>
<br>
<br>
Using the itk-master-git-static as built before, (BUILD_SHARED_LIBS<br>
OFF)<br>
<br>
<br>
<br>
<br>
<br>
In CMakeLists.txt for the project, add SHARED keyword to the library<br>
defninition:<br>
<br>
<br>
<br>
15 ADD_LIBRARY(Example_ITKFilterLib SHARED ITKFilterLib.cxx )<br>
<br>
Then use cmake + make to build the libExample_ITKFilterLib.so library.<br>
<br>
<br>
<br>
<br>
<br>
Then I can invoke g++ as follows<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
build]$ g++ ../ITKFilterLib/ITKFilterLibTest.cxx -o testcomp -L . -l<br>
Example_ITKFilterLib -I ../ITKFilterLib/<br>
<br>
<br>
<br>
Even if the itk-master-static is not available in that environment,<br>
this succeeds, and I believe this is what I want. I don’t want to have<br>
a statically linked final executable, but rather a .so library.<br>
<br>
<br>
<br>
<br>
<br>
However …<br>
<br>
<br>
<br>
I encountered another hitch trying to apply this to my actual project.<br>
If there were any FileWriter and FileReader present in the library, it<br>
would not build, complaining about position-dependent symbols in<br>
several IO libraries , most of which I was not actually wanting to use<br>
at all. This happened at the step of trying to build the .so library<br>
using the makefile created by cmake:<br>
<br>
<br>
<br>
/usr/bin/ld:<br>
/dls_sw/apps/itk/itk-master-static/lib/libitkgdcmjpeg8-4.10.a(jerror.c.o):<br>
relocation R_X86_64_32S against `.text' can not be used when making a<br>
shared object; recompile with -fPIC<br>
<br>
/dls_sw/apps/itk/itk-master-static/lib/libitkgdcmjpeg8-4.10.a: could<br>
not read symbols: Bad value<br>
<br>
<br>
<br>
<br>
<br>
Removing any reference to FileReader and FileWriter gets rid of this<br>
problem.<br>
<br>
<br>
<br>
Thanks!<br>
<br>
<br>
<br>
<br>
<br>
As a further note:<br>
<br>
<br>
<br>
There are also some directions in the comments of the ITKFilterLib<br>
example that did not turn out to be necessary in my project. I did not<br>
have to create global objects for poitners or image containiers<br>
outside the scope of the class and still did not have to #include itkImage.h in<o:p></o:p></p>
<p class="MsoNormal">the main program.<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">I placed the typedef’s inside the class and the instantiations of the<br>
smart poitners in the class constructor. I don’t see that this extra<br>
complication in the example is necessary unless it is platform dependent?<br>
<br>
<br>
<br>
ITKFilterLib.cxx from ItkApps example:<br>
<br>
<br>
<br>
<br>
<br>
23 #include "ITKFilterLib.h"<br>
<br>
24<br>
<br>
25 // Nasty local globals inside .cxx file to hide itk from the real world.<br>
<br>
26 // Can't put this variable in the class definition otherwise we'd have<br>
to<br>
<br>
27 // include itkImage.h in every program using this class.<br>
<br>
28 // The typedef h_itkFilterLibeDataType is in itkFilterLib.h to hide<br>
<br>
29 // templates<br>
<br>
30 typedef itk::Image<g_ItkFilterLibDataType,3> g_ImageType;<br>
<br>
31 g_ImageType::Pointer g_InputImage;<br>
<br>
32 g_ImageType::Pointer g_OutputImage;<br>
<br>
<br>
<br>
I did not find this to be necessary in my project.<br>
<br>
<br>
<br>
<br>
<br>
33<br>
<br>
34<br>
<br>
35 //<br>
<br>
36 //<br>
<br>
37 // The first filter in the .lib<br>
<br>
38 //<br>
<br>
39 //<br>
<br>
40<br>
<br>
41 /** The next lines are used to include the definition of the filter<br>
<br>
42 * we want to install in the .lib, define a typedef for it, and create<br>
<br>
43 * a "smart" pointer to hold it.<br>
<br>
44 * CHANGE HERE: The filter to be instantiated.<br>
<br>
45 **/<br>
<br>
46 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"<br>
<br>
47 typedef itk::CurvatureAnisotropicDiffusionImageFilter<g_ImageType,<br>
<br>
48 g_ImageType> g_AnisoFilterType;<br>
<br>
49 g_AnisoFilterType::Pointer g_anisoFilter;<br>
<br>
50<br>
<br>
<br>
<br>
I also did not find it to be necessary to have this sort of typedef<br>
and instantiation of the object at global scope in my project.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
From: Dženan Zukić [<a href="mailto:dzenanz@gmail.com">mailto:dzenanz@gmail.com</a>]<br>
Sent: 23 March 2016 14:39<br>
To: Atwood, Robert (DLSLtd,RAL,SCI)<br>
Cc: Insight-users<br>
Subject: Re: [ITK-users] stand-alone lib -- ITKApps/ITKFilterLib<br>
<br>
<br>
<br>
Hi Robert,<br>
<br>
<br>
<br>
BUILD_SHARED_LIBS OFF is the crucial setting. You can keep the rest of<br>
options on defaults.<br>
<br>
<br>
<br>
Your CMake code looks OK. You should execute the following from your<o:p></o:p></p>
<p class="MsoNormal">folder:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
cmake .<br>
<br>
make<br>
<br>
<br>
<br>
During CMake step you should configure options (point to the itk-build<br>
folder which was configured with BUILD_SHARED_LIBS OFF). Afterwards,<br>
do not invoke g++ directly - invoke make, which supplies correct<br>
include directories and link libraries so you don't run into a thousand errors.<br>
<br>
<br>
<br>
Regards,<br>
<br>
Dženan<br>
<br>
<br>
<br>
On Tue, Mar 22, 2016 at 6:25 AM, <<a href="mailto:Robert.Atwood@diamond.ac.uk">Robert.Atwood@diamond.ac.uk</a>><o:p></o:p></p>
<p class="MsoNormal">wrote:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
Hi,<br>
Thanks, Dženan, for the hint. But, does anyone have specific<br>
information on exactly which options to set in each of: the ITK cmake<br>
options; and the project cmake options, or the plain g++ for building<br>
an external program to link to the library, for this to work ? There<br>
appear to be a few that might be related to this. Because, so far,<br>
simply changing the build options of the ITK installation didn’t work. See<o:p></o:p></p>
<p class="MsoNormal">below for even more details .<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
Thanks<br>
<br>
Robert<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Options selected in the project:<br>
<br>
ITK_DIR<br>
/dls_sw/apps/itk/itk-master-static/lib/cmake/ITK-4.10<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
In the ITK with installation to itk-master-static:<br>
<br>
I have tried some combinations of these options but, you know, it<br>
takes a while to rebuild ITK even though the computer is pretty good.<br>
<br>
<br>
<br>
BUILD_POSITION_DEPENDENT_CODE OFF (I don’t think this should be ON<br>
because that really wouldn’t work? )<br>
<br>
BUILD_SHARED_LIBS OFF (or ON)<br>
<br>
CMAKE_CXX_FLAGS -fPIC (or default)<br>
<br>
CMAKE_EXE_LINKER_FLAGS -fPIC (or default)<br>
<br>
CMAKE_STATIC_LINKER_FLAGS (should this be set too? )<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
The CMakeLists in the project file – only small modification from the<br>
original to ‘BUILD_OUTSIDE_INSIGHT_APPICATIONS’. The project builds<br>
using the Cmake makefile, producing the library and the executable<br>
<br>
But trying to build either the ‘main’ procedure provided with linking<br>
to that library, or even simplifying the ‘main’ to do virtually<br>
nothing except instantiate the object, results in 1000 error messages<br>
of ‘undefined symbols’<br>
<br>
<br>
<br>
1 PROJECT(Example_ITKFilterLib)<br>
<br>
2<br>
<br>
3 #REMOVED 'IF (BUILD_OUTSIDE_INSIGHT_APPLICATIONS)'<br>
<br>
4<br>
<br>
5 FIND_PACKAGE(ITK)<br>
<br>
6 IF(ITK_FOUND)<br>
<br>
7 INCLUDE(${ITK_USE_FILE})<br>
<br>
8 ELSE(ITK_FOUND)<br>
<br>
9 MESSAGE(FATAL_ERROR<br>
<br>
10 "Cannot build ITKApps without ITK. Please set ITK_DIR.")<br>
<br>
11 ENDIF(ITK_FOUND)<br>
<br>
12<br>
<br>
13 #REMOVED 'ENDIF(BUILD_OUTSIDE_INSIGHT_APPLICATIONS)'<br>
<br>
14<br>
<br>
15 ADD_LIBRARY(Example_ITKFilterLib ITKFilterLib.cxx )<br>
<br>
16 INSTALL_TARGETS(/lib Example_ITKFilterLib)<br>
<br>
17 TARGET_LINK_LIBRARIES(Example_ITKFilterLib ${ITK_LIBRARIES})<br>
<br>
18<br>
<br>
19 ADD_EXECUTABLE(Example_ITKFilterLibTest ITKFilterLibTest.cxx )<br>
<br>
20 INSTALL_TARGETS(/bin Example_ITKFilterLibTest)<br>
<br>
21 TARGET_LINK_LIBRARIES(Example_ITKFilterLibTest<br>
Example_ITKFilterLib)<br>
<br>
<br>
<br>
<br>
<br>
build]$ ls -l<br>
<br>
total 2508<br>
<br>
-rw-rw-r-- 1 kny48981 kny48981 14393 Mar 22 10:02 CMakeCache.txt<br>
<br>
drwxrwxr-x 6 kny48981 kny48981 4096 Mar 22 10:05 CMakeFiles<br>
<br>
-rwxrwxr-x 1 kny48981 kny48981 1417263 Mar 22 10:05<br>
Example_ITKFilterLibTest<br>
<br>
drwxrwxr-x 2 kny48981 kny48981 4096 Mar 22 10:02<o:p></o:p></p>
<p class="MsoNormal">ITKIOFactoryRegistration<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
-rw-rw-r-- 1 kny48981 kny48981 7933 Mar 22 10:02 Makefile<br>
<br>
-rw-rw-r-- 1 kny48981 kny48981 1092874 Mar 22 10:05<br>
libExample_ITKFilterLib.a<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
build]$ g++ -o testcomp ../ITKFilterLib/ITKFilterLibTest.cxx -I<br>
../ITKFilterLib -L . -l Example_ITKFilterLib >& out &<br>
<br>
<br>
<br>
… generates 1100 messages …<br>
<br>
<br>
<br>
<br>
<br>
1 ./libExample_ITKFilterLib.a(ITKFilterLib.o): In function<br>
`itk::MemoryAllocationError::MemoryAllocationError(std::basic_string<c<br>
har,<br>
std::char_traits<char>, std::allocat<br>
<br>
2<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk21MemoryAllocationErrorC2ERKSsjS2_S2_[_ZN3<br>
itk21MemoryAllocationErrorC5ERKSsjS2_S2_]+0x39):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `itk::ExceptionObject:<br>
<br>
…<br>
<br>
1106<br>
ITKFilterLib.cxx:(.text._ZNK3itk12NeighborhoodIPfLj3ENS_21Neighborhood<br>
AllocatorIS1_EEE9PrintSelfERSoNS_6IndentE[itk::Neighborhood<float*,<br>
3u, itk::NeighborhoodAllocato<br>
<br>
1107 collect2: ld returned 1 exit status<br>
<br>
<br>
<br>
<br>
<br>
Minimal example main:<br>
<br>
<br>
<br>
1 #include "ITKFilterLib.h"<br>
<br>
2 int main(int, char **) {<br>
<br>
3 int inputDimSize[3];<br>
<br>
4 float inputOrigin[3];<br>
<br>
5 float inputSpacing[3];<br>
<br>
6 inputDimSize[0] = 5;<br>
<br>
7 inputDimSize[1] = 5;<br>
<br>
8 inputDimSize[2] = 5;<br>
<br>
9 inputOrigin[0] = 0;<br>
<br>
10 inputOrigin[1] = 0;<br>
<br>
11 inputOrigin[2] = 0;<br>
<br>
12 inputSpacing[0] = 1;<br>
<br>
13 inputSpacing[1] = 1;<br>
<br>
14 inputSpacing[2] = 1;<br>
<br>
15<br>
<br>
16 itkFilterLib filter(inputDimSize, inputOrigin, inputSpacing);<br>
<br>
17 return (true);<br>
<br>
18 }<br>
<br>
<br>
<br>
g++ -o testmin minimal_example.cxx -I ../ITKFilterLib -L . -l<br>
Example_ITKFilterLib >& out<br>
<br>
<br>
<br>
<br>
<br>
Same output AFAICT:<br>
<br>
<br>
<br>
<br>
<br>
1 ./libExample_ITKFilterLib.a(ITKFilterLib.o): In function<br>
`itk::MemoryAllocationError::MemoryAllocationError(std::basic_string<c<br>
har,<br>
std::char_traits<char>, std::alloca<br>
<br>
2<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk21MemoryAllocationErrorC2ERKSsjS2_S2_[_ZN3<br>
itk21MemoryAllocationErrorC5ERKSsjS2_S2_]+0x39):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">undefined reference to `itk::ExceptionObject:<br>
<br>
….<br>
<br>
<br>
<br>
From: Dženan Zukić [<a href="mailto:dzenanz@gmail.com">mailto:dzenanz@gmail.com</a>]<br>
Sent: 21 March 2016 20:21<br>
To: Atwood, Robert (DLSLtd,RAL,SCI)<br>
Cc: Insight-users<br>
Subject: Re: [ITK-users] stand-alone lib -- ITKApps/ITKFilterLib<br>
<br>
<br>
<br>
Hi Robert,<br>
<br>
<br>
<br>
maybe you need to link to ITK statically? To accomplish this you<br>
probably need to build ITK as static libraries (it is a configuration<br>
option in CMake).<br>
<br>
<br>
<br>
Regards,<br>
<br>
Dženan<br>
<br>
<br>
<br>
On Mon, Mar 21, 2016 at 12:50 PM, <<a href="mailto:Robert.Atwood@diamond.ac.uk">Robert.Atwood@diamond.ac.uk</a>><o:p></o:p></p>
<p class="MsoNormal">wrote:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
Hi,<br>
This example, ITKApps/ITKFilterLib, appears to be an example of what I<br>
want to do , bundle or encapsulate a specific ITK-based filter into a<br>
library so that another program may just call it without having to<br>
have the ITK source installation available.<br>
However, a basic test for me is not working.<br>
<br>
I just tried to compile the test example from command line after<br>
building the library with Cmake as usual. I get hundreds of 'undefined<br>
reference', as if I have to link with all the ITK libs anyways.<br>
Am I missing something?<br>
Thanks<br>
<br>
<br>
<br>
<br>
g++ -o testcomp ../ITKFilterLib/ITKFilterLibTest.cxx -I<br>
g++ ../ITKFilterLib/ -L<br>
. -l Example_ITKFilterLib<br>
<br>
<br>
First few lines of output:<br>
<br>
./libExample_ITKFilterLib.a(ITKFilterLib.o): In function<br>
`itk::MemoryAllocationError::MemoryAllocationError(std::basic_string<c<br>
har, std::char_traits<char>, std::allocator<char> > const&, unsigned<br>
int, std::basic_string<char, std::char_traits<char>,<br>
std::allocator<char> > const&, std::basic_string<char,<br>
std::char_traits<char>, std::allocator<char><br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">const&)':<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk21MemoryAllocationErrorC2ERKSsjS2_S2_[_ZN3<br>
itk21MemoryAllocationErrorC5ERKSsjS2_S2_]+0x39):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to<br>
`itk::ExceptionObject::ExceptionObject(std::basic_string<char,<br>
std::char_traits<char>, std::allocator<char> > const&, unsigned int,<br>
std::basic_string<char, std::char_traits<char>, std::allocator<char> ><br>
const&, std::basic_string<char, std::char_trait<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk21MemoryAllocationErrorC2ERKSsjS2_S2_[_ZN3<br>
itk21MemoryAllocationErrorC5ERKSsjS2_S2_]+0x44):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `vtable for itk::MemoryAllocationError'<br>
./libExample_ITKFilterLib.a(ITKFilterLib.o): In function<br>
`itk::ProcessAborted::ProcessAborted(char const*, unsigned int)':<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk14ProcessAbortedC2EPKcj[_ZN3itk14ProcessAb<br>
ortedC5EPKcj]+0x33):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `itk::ExceptionObject::ExceptionObject(char<br>
const*, unsigned int, char const*, char const*)'<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk14ProcessAbortedC2EPKcj[_ZN3itk14ProcessAb<br>
ortedC5EPKcj]+0x3e):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `vtable for itk::ProcessAborted'<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk14ProcessAbortedC2EPKcj[_ZN3itk14ProcessAb<br>
ortedC5EPKcj]+0x4f):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `itk::ExceptionObject::SetDescription(char const*)'<o:p></o:p></p>
<p class="MsoNormal">ITKFilterLib.cxx:(.text._ZN3itk14ProcessAbortedC2EPKcj[_ZN3itk14ProcessAb<br>
ortedC5EPKcj]+0x62):<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">undefined reference to `itk::ExceptionObject::~ExceptionObject()'<br>
<br>
<br>
<br>
This is on a Linux Red Hat with ITK git master today (March 21 2016)<br>
<br>
cmake --version<br>
cmake version 2.8.12.2<br>
<br>
/proc/version:<br>
<br>
Linux version 2.6.32-573.18.1.el6.x86_64<br>
(<a href="mailto:mockbuild@x86-010.build.bos.redhat.com">mockbuild@x86-010.build.bos.redhat.com</a>) (gcc version 4.4.7 20120313<br>
(Red Hat 4.4.7-16) (GCC) ) #1 SMP Wed Jan 6 11:20:49 EST 2016<br>
<br>
<br>
<br>
--<br>
This e-mail and any attachments may contain confidential, copyright<br>
and or privileged material, and are for the use of the intended<br>
addressee only. If you are not the intended addressee or an authorised<br>
recipient of the addressee please notify us of receipt by returning<br>
the e-mail and do not use, copy, retain, distribute or disclose the<br>
information in or attached to the e-mail.<br>
Any opinions expressed within this e-mail are those of the individual<br>
and not necessarily of Diamond Light Source Ltd.<br>
Diamond Light Source Ltd. cannot guarantee that this e-mail or any<br>
attachments are free from viruses and we cannot accept liability for<br>
any damage which you may sustain as a result of software viruses which<br>
may be transmitted in or with the message.<br>
Diamond Light Source Limited (company no. 4375679). Registered in<br>
England and Wales with its registered office at Diamond House, Harwell<br>
Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United<br>
Kingdom<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br>
<br>
<br>
<br>
<br>
--<br>
<br>
This e-mail and any attachments may contain confidential, copyright<br>
and or privileged material, and are for the use of the intended<br>
addressee only. If you are not the intended addressee or an authorised<br>
recipient of the addressee please notify us of receipt by returning<br>
the e-mail and do not use, copy, retain, distribute or disclose the<br>
information in or attached to the e-mail.<br>
Any opinions expressed within this e-mail are those of the individual<br>
and not necessarily of Diamond Light Source Ltd.<br>
Diamond Light Source Ltd. cannot guarantee that this e-mail or any<br>
attachments are free from viruses and we cannot accept liability for<br>
any damage which you may sustain as a result of software viruses which<br>
may be transmitted in or with the message.<br>
Diamond Light Source Limited (company no. 4375679). Registered in<br>
England and Wales with its registered office at Diamond House, Harwell<br>
Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United<br>
Kingdom<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
<br>
This e-mail and any attachments may contain confidential, copyright<br>
and or privileged material, and are for the use of the intended<br>
addressee only. If you are not the intended addressee or an authorised<br>
recipient of the addressee please notify us of receipt by returning<br>
the e-mail and do not use, copy, retain, distribute or disclose the<br>
information in or attached to the e-mail.<br>
Any opinions expressed within this e-mail are those of the individual<br>
and not necessarily of Diamond Light Source Ltd.<br>
Diamond Light Source Ltd. cannot guarantee that this e-mail or any<br>
attachments are free from viruses and we cannot accept liability for<br>
any damage which you may sustain as a result of software viruses which<br>
may be transmitted in or with the message.<br>
Diamond Light Source Limited (company no. 4375679). Registered in<br>
England and Wales with its registered office at Diamond House, Harwell<br>
Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United<br>
Kingdom<br>
<br>
<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><o:p></o:p></p>
<p class="MsoNormal"><br>
-- <br>
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt
by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br>
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
<br>
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br>
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<p align="justify"> </p>
<p align="justify">-- </p>
<p align="justify">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br />Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. <br />Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br />Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br /> </p></body>
</html>