Haris Saybasili | 1 May 2006 10:37
Picon

creating ITK dll with MS Visual C++ 6.0

Hi,

I am trying to create a dll using ITK. I am trying a very simple application:

---------------
    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);
------------------

There is nothing more in it. But I have some problems with msvc 6.0. I modified the makefile (.mak) exported from Visual C++ project, included all the ITK libraries, and other necessary libraries. But when I try to compile (make) it with nmake provided by msvc 6.0:

.................
    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 <at> <at> 3V?$basic_ostream <at> DU?$char_traits <at> D <at> std <at> <at> <at> 1 <at> A)
myitk.obj : error LNK2001: unresolved external symbol "__int64 const std::_Fpz" (?_Fpz <at> std <at> <at> 3_JB)
myitk.obj : error LNK2001: unresolved external symbol "private: static class std::locale::_Locimp * std::locale::_Locimp::_Global" (?_Global <at> _Locimp <at> locale <at> std <at> <at> 0PAV123 <at> A)
myitk.obj : error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt <at> id <at> locale <at> std <at> <at> 0HA)
.\Debug\myitk.dll : fatal error LNK1120: 4 unresolved externals


How this can happen?? How can it be unable to find cout??? I don't know what to do.

I know that this is a really bad idea to use visual c++ 6.0 compiler, as it is old and does not complies with ANSI C++. But I have to use it. I managed to compile it as a static library, but I need a dynamic one.

Anybody has an idea?

Thanks in advance,

haris

_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
Martin Urschler | 1 May 2006 11:01

Re: creating ITK dll with MS Visual C++ 6.0

hi haris,

Why aren't you using cmake to compile your dll?
It's a lot simpler since all you have to do for your project is 
something like this:

CMakeLists.txt

PROJECT(MyDllUsingItk)

# Find ITK.
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
   INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
   MESSAGE(FATAL_ERROR
           "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

ADD_LIBRARY(MyDllUsingItk SHARED sourceCode.cpp ...)

this cmake file will produce the nmake makefile for visual c++ via 
CMakeSetup.exe

furthermore I can't see where you specify the export declarations for 
your method that you want to put into a dll...
you will need something like this:

#ifdef MY_DLL_EXPORTS
    #define MY_DLL_EXT __declspec(dllexport)
#else
    #define MY_DLL_EXT __declspec(dllimport)
#endif

void MY_DLL_EXT myMethodSolvingAnyProblem()
{
...
}

class MY_DLL_EXT MyClassDoingSomethingReallyCool
{
...
}

if you have declared these things but didn't put it into the code 
snippet ... then my apologies ...
but if these things don't tell you anything you should look into your 
favourite Visual C++ book to learn more about how to write a dll

regards,
Martin
Haris Saybasili | 1 May 2006 12:32
Picon

(update) how to create ITK dll with visual c++ 6.0?

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 <at> <at> 3V?$basic_ostream <at> DU?$char_traits <at> D <at> std <at> <at> <at> 1 <at> A)
myitk.obj : error LNK2001: unresolved external symbol "__int64 const std::_Fpz" (?_Fpz <at> std <at> <at> 3_JB)
myitk.obj : error LNK2001: unresolved external symbol "private: static class std::locale::_Locimp * std::locale::_Locimp::_Global" (?_Global <at> _Locimp <at> locale <at> std <at> <at> 0PAV123 <at> A)
myitk.obj : error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt <at> id <at> locale <at> std <at> <at> 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@...
http://www.itk.org/mailman/listinfo/insight-users
Luis Ibanez | 1 May 2006 13:01
Favicon
Gravatar

Re: (update) how to create ITK dll with visual c++ 6.0?


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 <at>  <at> 3V?$basic_ostream <at> DU?$char_traits <at> D <at> std <at>  <at>  <at> 1 <at> A)
> myitk.obj : error LNK2001: unresolved external symbol "__int64 const 
> std::_Fpz" (?_Fpz <at> std <at>  <at> 3_JB)
> myitk.obj : error LNK2001: unresolved external symbol "private: static 
> class std::locale::_Locimp * std::locale::_Locimp::_Global" 
> (?_Global <at> _Locimp <at>  locale <at> std <at>  <at> 0PAV123 <at> A)
> myitk.obj : error LNK2001: unresolved external symbol "private: static 
> int std::locale::id::_Id_cnt" (?_Id_cnt <at> id <at> locale <at> std <at>  <at> 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@...
> http://www.itk.org/mailman/listinfo/insight-users
Haris Saybasili | 1 May 2006 13:04
Picon

Re: (update) how to create ITK dll with visual c++ 6.0?

Hi Luis,

my CMakeLists.txt file is:

-----------------------------------------------------
PROJECT(myitk)

# Find ITK.
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
  MESSAGE(FATAL_ERROR
          "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

ADD_LIBRARY(mytik SHARED myitk.cxx)
---------------------------------------------------------------------------

Thanks a lot,

haris

On 5/1/06, Luis Ibanez <luis.ibanez-5opLkZggLXlBDgjK7y7TUQ@public.gmane.org> 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 <at> <at> 3V?$basic_ostream <at> DU?$char_traits <at> D <at> std <at> <at> <at> 1 <at> A)
> myitk.obj : error LNK2001: unresolved external symbol "__int64 const
> std::_Fpz" (?_Fpz <at> std <at> <at> 3_JB)
> myitk.obj : error LNK2001: unresolved external symbol "private: static
> class std::locale::_Locimp * std::locale::_Locimp::_Global"
> (?_Global <at> _Locimp <at> locale <at> std <at> <at> 0PAV123 <at> A)
> myitk.obj : error LNK2001: unresolved external symbol "private: static
> int std::locale::id::_Id_cnt" (?_Id_cnt <at> id <at> locale <at> std <at> <at> 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-RyaoCGfWeh4@public.gmane.org
> http://www.itk.org/mailman/listinfo/insight-users



_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
Luis Ibanez | 1 May 2006 13:59
Favicon
Gravatar

Re: (update) how to create ITK dll with visual c++ 6.0?


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@... 
> <mailto:luis.ibanez@...>> 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 <at>  <at> 3V?$basic_ostream <at> DU?$char_traits <at> D <at> std <at>  <at>  <at> 1 <at> A)
>      > myitk.obj : error LNK2001: unresolved external symbol "__int64 const
>      > std::_Fpz" (?_Fpz <at> std <at>  <at> 3_JB)
>      > myitk.obj : error LNK2001: unresolved external symbol "private:
>     static
>      > class std::locale::_Locimp * std::locale::_Locimp::_Global"
>      > (?_Global <at> _Locimp <at>  locale <at> std <at>  <at> 0PAV123 <at> A)
>      > myitk.obj : error LNK2001: unresolved external symbol "private:
>     static
>      > int std::locale::id::_Id_cnt" (?_Id_cnt <at>  id <at> locale <at> std <at>  <at> 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@... <mailto:Insight-users@...>
>      > http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
Luis Ibanez | 1 May 2006 15:06
Favicon
Gravatar

Re: BSpline - deformable transformation with default multiresolution framework


Hi Reinhard,

I may not have been clear enough, I apologize for that.

The BSpline deformable transform itself *IS* compatible
with the Multi-Resolution framework in ITK.

What I meant in my previous email is that the approach
of creating *multiple* BSPline transforms, by changing
their grids resolution is not something you can plug
directly into the Multi-Resolution framework.

In principle you could change the Transform in the middle
of the registration process, e.g. by taking advantage of
an Iteration event, as you suggested. However, you will have
to be careful to make sure that the array of parameters that
is passed to the optimizer and to the Metric is resized
correctly in order to reflect the change in number of
parameters from the Transform.

    Regards,

       Luis

=========================
Reinhard Hameeteman wrote:
> Hi Luis and Markus,
> 
> Now this last post worries me a bit. I don't really see a reason why
> the B-spline transform shouldn't work with the multiresolution
> framework. But I think you both are referring to up-sampling the node
> density of the transform when going to a higher resolution level,
> which is not done in the multiresolution framework right? But since
> the first thing done in the registration is invoke the iteration event
> it should very wel be possible to up-sample the grid at that point,
> wouldn't it?
> 
> Regards,
> Reinhard
> 
> 2006/4/30, Luis Ibanez <luis.ibanez@...>:
> 
>>
>> Hi Markus,
>>
>> You are correct in your observation.
>>
>> The approach of using a multi-resolution BSpline grid is a different
>> mechanism than the one used in the standard multi-resolution framework.
>>
>> In this case, as you pointed out, we are refining the transform itself.
>>
>> At this point there is no direct way of integrating the BSpline multi
>> resolution with the pyramidal framework for multi-resolution
>> registration. It is, however, a very interesting undertaking and it will
>> be worth to invest some time on it if you find that in alignment with
>> your current work.
>>
>> Please let us know if you need any help with the details of setting
>> up such a framework.
>>
>>
>>
>>     Thanks
>>
>>
>>        Luis
>>
>>
>> ========================
>> Markus Weigert wrote:
>> > Hi all,
>> >
>> > I had a look at the multiresolution example of BSpline - registration
>> > (example 6)
>> > and noticed, that using BSpline in this way doesn't conform to the
>> > multiresolution
>> > registration framework (especially, it uses two transform objects and
>> > itkImageRegistrationMethod
>> > instead of using itkMultiResolutionImageRegistrationMethod).
>> > My question is now:
>> > Is there a way to integrate this transform in the multiresolution
>> > framework to use it like any other transform,
>> > or do I have to change my code to deal with different registration
>> > schemes???
>> > My goal is a class, which uses the multiresolution framework and
>> > provides several metrics, optimizers,
>> > transforms and interpolators in a unified way.
>> >
>> > Regards,
>> > Markus
>> >
>> >
>> > 
>> ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Insight-users mailing list
>> > Insight-users@...
>> > http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users@...
>> http://www.itk.org/mailman/listinfo/insight-users
>>
> 
> 
Luis Ibanez | 1 May 2006 15:08
Favicon
Gravatar

Re: Xiaoming: DeformableImageRegistration1 usage problem


Hi Xiaoming,

 From what directory are you running this command line ?

In what directory do you put the file
                 FiniteElementRegistrationParameters1.txt ?

If you are not in the same directory where the parameter file
is, then you should give the full path to the file as the
command line argument to the DeformableRegistration1 program.

    Regards,

       Luis

------------------
yiming yin wrote:
> Hi Luis, one more question, I am a bit stuck on this due to my lack of 
> knowledge on CMake and C++ together. Still learnering ;)
> This is the error I get.
> C:\Insight\InsightToolkit-2.6.0\Examples\try\bin\Debug>DeformableRegistration1 
> F
> initeElementRegistrationParameters1.txt
> Reading config file...FiniteElementRegistrationParameters1.txt
> No configuration file specified...quitting.
> Thank you.
> Sincerely
> Xiaoming
>  
> On 4/30/06, *yiming yin* <yimingyinster@... 
> <mailto:yimingyinster@...>> wrote:
> 
>     thank you so much.
>     Sincerely
>     Xiaoming
> 
>      
>     On 4/30/06, *Luis Ibanez* <luis.ibanez@...
>     <mailto:luis.ibanez@...>> wrote:
> 
> 
>         Hi Xiaming,
> 
>         You may want to take a look at the two example parameter files
>         provided in
> 
> 
>               Insight/Examples/Data/
>                  FiniteElementRegistrationParameters1.txt
>                  FiniteElementRegistrationParameters2.txt
> 
> 
>         You select the cost function when you select the image metric,
>         in line 33 of the parametric file.
> 
>         Your options are Mutual Information, Normalized Correlation
>         and Mean Squares.
> 
> 
> 
>            Regards,
> 
> 
>                Luis
> 
> 
> 
>         ====================
>         yiming yin wrote:
>>  Hi, I believe I am also having the same trouble as Mr. Paci, I
>         am not
>>  sure what to feed into the parameter file which the
>>  DeformableImageRegistration1.cxx is asking. I am also
>         wondering where to
>>  look for information on each function. I understand that the
>         software
>>  guide provide explaination on each of the function. However, I
>         got the
>>  sense that the software guide only explain what each lines of
>         the code
>>  DeformableImageRegistration1.cxx does, it does not ever
>         provide how to
>>  go about using the function. Maybe I am not looking at the correct
>>  place? I am wondering if there are other documentation which I
>         should
>>  look at. Thank you.
>>
>>  Sincerely
>>  Xiaoming
>>
>>
>>
>         ------------------------------------------------------------------------
>>
>>  _______________________________________________
>>  Insight-users mailing list
>>  Insight-users@... <mailto:Insight-users@...>
>>  http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> 
Kevin Ming | 1 May 2006 20:43
Picon

3D Resampling

Hi,

I'm trying to rigidly transform some 3D image data for test in registration, but can't seem to figure out what kind problems I'm running into:

1)  The program only seems to resample the 1st out of a total of 12 slices from my 3D image, all other slices are just a repeat of the first slice.  I tried playing around with spacing[2] = x for Dimension = 3 where x is any value greater than 0, but instead the program would give me every slice other than the 1st one black.

2)  Also, all the output images seem to give me really high brightness and contrast values.  For example my original images have brightness = 2204933.4355 and contrast = 4277002.0027, and the output would be brightness = 44324303030.1732 and contrast = 9999999.0000.  Does this have to do with the fact that I changeed the InputPixelType and OutputPixelType to float?

In generally I think it's my spacing and maybe origin values that are creating these problems, so here are what I think they should be:

Spacing (or in ANALYZE, Size) (mm):  x = 0.01, y = 0.01, z = 0.00
Origin (same name in ANALYZE) (vxl):  x = 0.00, y = 0.00, z = 0.00


Thank You,
Kevin

_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
Mathieu Malaterre | 1 May 2006 21:05
Favicon

Re: re:re:why not ITK can read the spacing correctly?

Yixun Liu wrote:
> Hi Luis,
> Thank your help!
> Yes I compare it with the dicom header.
>  
> One question. If the dicom files are not consecutive. Could ITK read 
> them correctly?

No. Special care was done in GDCM so that if non-consecutive -let say
scout views- are provided as input ITK-GDCM will let the user know that
a 3D volume can not be reconstructed from the input images.

> Another question. I use DICOMImageIO2 and DicomImageIO to read a same 
> series. The DICOMImageIO2 can read  the spacing[2] correctly, but 
> DICOMImageIO is error. Why?

As other people mention, you should not use DICOM2 anymore. If you use
Dicom you should be fine since it transparently default to calling
GDCMImageIO. In anyway -I insist- the spacing calculation done in
ITK-GDCM is done correctly.

We really appreciate user feedback, but in your case you do not provide
a lot of information on your conclusion, technically this is also known
as FUD(*) ;)
So, please, spend the time to provide any/all of the following:
* What other software you are using,
* Some slices from your data,
* a dcmdump/DicomPrintPatientInformation of your data,
* Tcl/Python/c++ code to reproduce the bug.

Please keep in mind that user discover ITK, in browsing this mailing
list, so if you believe you found a bug, please provide a detailed
explanation of the issue, a way to reproduce or any details that
*undoubtly* demonstrate the issue in ITK.

Regards
Mathieu
(*)http://en.wikipedia.org/wiki/FUD

Gmane