Hi<br> You just need to change "importITK.cpp" to "importITK.h" and include it in your "test.cxx"<br><br><br><br><div class="gmail_quote">On Sat, Feb 14, 2009 at 6:43 AM, 李健 <span dir="ltr"><<a href="mailto:rongx2@live.cn">rongx2@live.cn</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<br>Linking CXX executable test<br>CMakeFiles/test.dir/test.o(.text+0x1be): In function `main':<br>/home/src/itk/test.cxx:23: undefined reference to `importITK<unsigned short, 2u>::importITK(unsigned int*, unsigned short*)'<br>
CMakeFiles/test.dir/test.o(.text+0x20d):/home/src/itk/test.cxx:28: undefined reference to `importITK<unsigned short, 2u>::GetOutput()'<br>collect2: ld returned 1 exit status<br>make[2]: *** [test] Error 1<br>make[1]: *** [CMakeFiles/test.dir/all] Error 2<br>
make: *** [all] Error 2<br> <br> <br>importITK is the name of the class I created. In main() funtion, I just invoked some member functions of the class importITK.<br> <br>
Thanks a lot.<br><br> <br><br>
<hr>
<br>
<br>Date: Fri, 13 Feb 2009 21:29:04 +0200<br>Subject: Re: [Insight-users] Linking problem when using itk<br>From: <a href="mailto:ufukmat@gmail.com" target="_blank">ufukmat@gmail.com</a><br>To: <a href="mailto:rongx2@live.cn" target="_blank">rongx2@live.cn</a><br>
<br>Could you please give the details of the errors.<br><br><br><br>
<div><div><div></div><div class="Wj3C7c">On Fri, Feb 13, 2009 at 9:22 PM, 李健 <span dir="ltr"><<a href="mailto:rongx2@live.cn" target="_blank">rongx2@live.cn</a>></span> wrote:<br>
</div></div><blockquote style="padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
<div>Dear all:<br> <br>I wrote a class to implement some member functions of itk using Linux. The class declaration is in a flie named by importITK.h, and the class definition is in a file named by importITK.cpp. And I wrote a fuction main() in a file named by test.cxx to invoke that class. I included all needed header files in three files. But something's wrong during liking in main() function: undefined reference to member functions of the class I created. <br>
<br>Here is my CMakeLists.txt:<br> <br>FIND_PACKAGE(ITK)<br>IF(ITK_FOUND)<br> INCLUDE(${ITK_USE_FILE})<br>ELSE(ITK_FOUND)<br> MESSAGE(FATAL_ERROR<br> "ITK not found. Please set ITK_DIR.")<br>ENDIF(ITK_FOUND)<br>
ADD_EXECUTABLE(test test.cxx importITK.cpp)<br>TARGET_LINK_LIBRARIES(test ITKCommon ITKBasicFilters ITKIO)<br> <br> <br>I think maybe something's wrong about the CmakeLists.txt I wrote.<br> <br>Thanks
a lot.<br><br>
<hr>
MSN 9.0 正式版上线,捆绑免费25G网络硬盘! <a href="http://im.live.cn/msn9/" target="_blank">立刻下载!</a></div><br></div></div>_____________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br><br></blockquote></div><br><br clear="all">
<br>-- <br>Ufuk MAT<br>Research Assistant<br><br>Bogazici University<br>Institute of Biomedical Engineering<br>34342, Bebek/Istanbul<br><br>Phone : +90 533 484 6301<br>Fax : +90 212 257 5030<br><br><br><br><br><br><hr>
使用新一代 Windows Live Mess
enger 轻松交流和共享! <a href="http://im.live.cn/messenger.aspx" target="_blank">立刻下载!</a></div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>