[Insight-users] (update) how to create ITK dll with visual c++ 6.0?

Luis Ibanez luis.ibanez at kitware.com
Mon May 1 07:59:36 EDT 2006


Hi Haris


It doesn't seem that you are using CMake for configuring your project.


Trying to do this by hand in Visual Studio is an interesting game, but
it is also a waste of your valuable time. CMake has been designed for
saving your time in the configuration process of project.

You could be doing image processing by now, instead of wasting your time
playing with the little box options in Visual Studio.



Here is the CMakeLists.txt file that you need in order to create a
shared library.



===================================

PROJECT(ExampleLibrary)

FIND_PACKAGE(ITK REQUIRED)
IF(ITK_FOUND)
   INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)

ADD_LIBRARY(myLibrary SHARED
sourceFile1.cxx
sourceFile2.cxx
sourceFile3.cxx
sourceFile4.cxx
)

TARGET_LINK_LIBRARIES(myLibrary
    ITKNumerics
    ITKIO
    ITKBasicFilters
)

===================================





As you will notice, the only special thing to add is the "SHARED"
modifier in the ADD_LIBRARY command.



Please use this CMakeLists.txt file template for configuring your project.


    Thanks


      Luis



=========================
Haris Saybasili wrote:
> Hi Luis,
> 
> I will also send you the .mak file that I added ITK libraries and some 
> Windows libraries manually. Maybe it can be helpful.
> 
> When I try compiling the project generated by cmake I have 44 errors, 
> all of which are undefined references. Even though I added the ITK 
> include files and libs to the environment, I could not compile it in 
> msvc++ editor. So I exported a makefile, and edited it. So far, I have 
> only 4 errors, the errors that I posted when making with "nmake".
> 
> Thanks again for your help.
> 
> Regards,
> 
> haris
> 
> On 5/1/06, *Luis Ibanez* <luis.ibanez at kitware.com 
> <mailto:luis.ibanez at kitware.com>> wrote:
> 
> 
>     Hi Haris
> 
>     Please post the CMakeLists.txt file that you wrote for this project.
> 
>     Thanks
> 
> 
>          Luis
> 
> 
> 
>     ====================
>     Haris Saybasili wrote:
>      > Hi,
>      >
>      > I tried cmake, it created the project. However, Visual C++ couldn't
>      > compile it. I had 44 errors, all of which was unresolved
>     references. I
>      > added additional lib and include libraries to the project, but no
>     luck.
>      > I exported the makefile, and edited it. I get the same error as
>     always:
>      >
>      > .................
>      >     Searching C:\ITK\bin\bin\Debug\itksys.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\kernel32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\user32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\gdi32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\winspool.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\comdlg32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\advapi32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\shell32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\ole32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\oleaut32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\uuid.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\odbc32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\odbccp32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\msvcrtd.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKAlgorithms.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKBasicFilters.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKCommon.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKDICOMParser.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKEXPAT.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKFEM.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkgdcm.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKIO.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkjpeg8.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkjpeg12.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkjpeg16.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKMetaIO.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itknetlib.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKniftiio.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKNrrdIO.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKNumerics.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkpng.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKSpatialObject.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKStatistics.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itktestlib.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itktiff.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkvcl.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkvnl.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkvnl_algo.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkvnl_inst.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itkzlib.lib:
>      >     Searching C:\ITK\bin\bin\Debug\ITKznz.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\OLDNAMES.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\msvcprtd.lib:
>      >     Searching C:\ITK\bin\bin\Debug\itksys.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\kernel32.lib:
>      >     Searching C:\MSVStudio6\VC98\lib\user32.lib:
>      > Done Searching Libraries
>      > myitk.obj : error LNK2001: unresolved external symbol "class
>      > std::basic_ostream<char,struct std::char_traits<char> > std::cout"
>      > (?cout at std@@3V?$basic_ostream at DU?$char_traits at D@std@@@1 at A)
>      > myitk.obj : error LNK2001: unresolved external symbol "__int64 const
>      > std::_Fpz" (?_Fpz at std@@3_JB)
>      > myitk.obj : error LNK2001: unresolved external symbol "private:
>     static
>      > class std::locale::_Locimp * std::locale::_Locimp::_Global"
>      > (?_Global at _Locimp@ locale at std@@0PAV123 at A)
>      > myitk.obj : error LNK2001: unresolved external symbol "private:
>     static
>      > int std::locale::id::_Id_cnt" (?_Id_cnt@ id at locale@std@@0HA)
>      > .\Debug\myitk.dll : fatal error LNK1120: 4 unresolved externals
>      >
>      >
>      > I had searched the net, and saw that these kind of errors are very
>      > common to vc++ 6.0. Is there anybody who succeded in creating an
>     ITK DLL
>      > with msvc++ 6.0?
>      >
>      > I am new to windows application development (I use linux
>     normally), so
>      > maybe I made a very elemental error.
>      >
>      > Thanks,
>      >
>      > haris
>      >
>      > PS: And for the DLL part, my code was like this:
>      >
>      > ----------------
>      > 1. myitk.h:
>      > ----------------
>      >
>      > #ifndef __HELLO_H
>      > #define __HELLO_H
>      > #ifndef __HELLO__
>      > #define __HELLOLIB__ __declspec(dllimport)
>      > #else
>      > #define __HELLOLIB__ __declspec(dllexport)
>      > #endif
>      > __HELLOLIB__ int myitkhello() ;
>      > #endif
>      >
>      > #include "C:\ITK\src\Code\Common\itkWin32Header.h"
>      > #include " itkImage.h"
>      >
>      >
>      > class myitk
>      > {
>      >   public:
>      >
>      >       myitk();
>      >
>      >       ~myitk();
>      >
>      > };
>      >
>      > ----------------
>      > myitk.cpp:
>      > ----------------
>      >
>      > #define __HELLO__
>      > #include "myitk.h"
>      >
>      > myitk::myitk() {
>      >
>      >
>      >     typedef itk::Image< unsigned short, 3 > ImageType;
>      >
>      >     ImageType::Pointer image = ImageType::New();
>      >     std::cout << "ITK Hello World !" << std::endl;
>      >     FILE *f;
>      >     f = fopen("c:/temp/itk.txt","w");
>      >     fprintf(f,"itk : hello world!!!\n");
>      >     fclose(f);
>      >
>      > }
>      >
>      >
>      > myitk::~myitk()
>      > {
>      >
>      > }
>      >
>      > __HELLOLIB__ int myitkhello() {
>      >
>      >     myitk mtk();
>      >     return 0;
>      > }
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      > _______________________________________________
>      > Insight-users mailing list
>      > Insight-users at itk.org <mailto:Insight-users at itk.org>
>      > http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 




More information about the Insight-users mailing list