Changes between Initial Version and Version 1 of GdalOgrCsharpCompile


Ignore:
Timestamp:
Apr 14, 2007, 3:33:54 PM (17 years ago)
Author:
tamas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GdalOgrCsharpCompile

    v1 v1  
     1
     2= GDAL/OGR CSharp interface compilation =
     3
     4This chapter describes the primary steps when creating the GDAL/OGR C# binaries from the source. In most cases using the precompiled binaries from the FWTools package would be sufficient instead of manually compiling the interface files.
     5
     6== Building on Windows ==
     7
     8For building the C# interface the GDAL core should be compiled first according to the [http://trac.osgeo.org/gdal/wiki/BuildingOnWindows Windows build instructions].
     9
     10=== Setting up a proper environment ===
     11
     12Before compiling the code you should prepare a number of environment variables for the compiler you use. If you don't want to bother with executing the proper vcvars*.bat you might use the development environment specific command prompt to accomplish this task. When using a Win64 compilation be careful to activate the x64 version of the command prompt installed on your system.
     13
     14=== Creating the SWIG interface code ===
     15
     16For creating the interface the swigwin-1.3.31 package should be downloaded and extracted. You should edit nmake.opt adding the actual location of the swig.exe file.
     17
     18For creating the interface execute the following command.
     19
     20{{{
     21C:\GDAL\swig\csharp> nmake /f makefile.vc interface
     22}}}
     23
     24=== Compiling the code ===
     25 
     26After creating the interface the code can be compiled as:
     27
     28{{{
     29C:\GDAL\swig\csharp> nmake /f makefile.vc
     30}}}
     31
     32Upon a successful compilation the following files are created:
     33
     34{{{
     35gdal_csharp.dll
     36ogr_csharp.dll
     37osr_csharp.dll
     38gdalconst_csharp.dll
     39gdal_wrap.dll
     40ogr_wrap.dll
     41osr_wrap.dll
     42gdalconst_wrap.dll
     43various sample applications (*.exe)
     44}}}
     45
     46*_csharp.dll is the managed part of the interface. You should add a reference to these assemblies for using the classes of the interface. These *_csharp.dll-s will load the corresponding *_wrap.dll which are the unmanaged part of the interface hosting the code of the gdal core.
     47
     48=== Testing the successful compilation ===
     49
     50For testing the successful compilation you can use:
     51
     52{{{
     53C:\GDAL\swig\csharp> nmake /f makefile.vc test
     54}}}
     55
     56This command will invoke some of the sample applications. For the proper execution the location of the proj.dll should be available in the PATH.
     57
     58== Specifying the MSVC version ==
     59
     60When compiling with the Visual Studio 2005 you might have to specify the compiler version by editing nmake.opt as:
     61
     62{{{
     63MSVC_VER=1400
     64}}}
     65
     66Alternatively you can pass this option to the nmake command line as
     67
     68{{{
     69C:\GDAL\swig\csharp> nmake /f makefile.vc MSVC_VER=1400
     70}}}
     71
     72== Using static vs. dynamic linking with the gdal libraries ==
     73
     74The default approach embeds the gdal/ogr code into the corresponding *_wrap.dll to minimize the dependency of the created files. In some cases you might want to link against the core gdal*.dll instead. To enable this option comment out the
     75
     76{{{
     77CSHARP_STATIC_LINKAGE = YES
     78}}}
     79
     80entry in the csharp.opt file.
     81
     82== Using MONO on Windows ==
     83
     84If you have the Windows version of the MONO package installed you can compile the C# code using the MONO compiler. In this case uncomment the following entry in csharp.opt:
     85
     86{{{
     87#MONO = YES
     88}}}
     89
     90And make mcs.exe available in the PATH.
     91
     92== Compiling on a WIN64 platform ==
     93
     94You can compile GDAL on a Win64 platform creating either Win32 or Win64 binaries. You should take care of setting up the proper environment variables for the corresponding compiler.
     95
     96For creating Win64 binaries you should compile the gdal core and the C# interface using the 64 bit compiler version, and specify WIN64=YES in nmake.opt.
     97
     98Alternatively you can pass this option to the nmake command line as
     99
     100{{{
     101C:\GDAL\swig\csharp> nmake /f makefile.vc WIN64=YES
     102}}}
     103
     104This setting will allow to specify the proper platform (/platform:anycpu) for the csharp compiler.
     105
     106IMPORTANT NOTICE:
     107The 64 bit version of the gdal will require to have 64 bit versions of the dependent libraries. For example you might have to compile a 64 bit version of the proj.dll so as to run the csharp make test successfully. 
     108
     109== Building on Linux/OSX ==
     110
     111TODO