<html><body bgcolor="#FFFFFF"><div>Hi,</div><div><br></div><div>first of all I would use the CMake variable ITK_LIBRARIES instead of specifying the different libs explicitly. This variable is set by the ITK use file, you're including. So,</div><div><br></div><div>TARGET_LINK_LIBRARIES(test ${ITK_LIBRARIES})</div><div><br></div><div>As your importITK class is a template class, the definitions have to be included as well whereever you use a specific instantiation of that template class. Therefore, the definitions are usually in a file with the extension txx to make clear that it contains template definitions only. It makes no sense to compile this file as long as it doesn't contain any explicit instantiations. These are usually placed in a corresponding cpp file. The txx file is commonly included at the bottom of the header file that contains the declaration of your templated class. Have a look at some of the ITK classes and you'll notice what I mean.</div><div><br></div><div>regards</div><div>Andreas<br><br>Am 13.02.2009 um 20:22 schrieb 李健 <<a href="mailto:rongx2@live.cn">rongx2@live.cn</a>>:<br><br></div><div></div><blockquote type="cite"><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.<rte_text></rte_text><br><br><hr>MSN 9.0 正式版上线,捆绑免费25G网络硬盘! <a href="http://im.live.cn/msn9/" target="_new">立刻下载!</a>
</div></blockquote><blockquote type="cite"><div><span>_____________________________________</span><br><span>Powered by <a href="http://www.kitware.com"><a href="http://www.kitware.com">www.kitware.com</a></a></span><br><span></span><br><span>Visit other Kitware open-source projects at</span><br><span><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br><span>Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ"><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a></a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a></span><br></div></blockquote></body></html>