[Gdal-dev] Re: FW: gdal swig csharp wrapper problems
Tamas Szekeres
szekerest at gmail.com
Thu May 24 16:56:18 EDT 2007
Scott,
Here are my suggestions to follow:
1. Since there were a high number of changes in the recent days I
would suggest to use the current svn-trunk. Many of the changes were
described at:
http://trac.osgeo.org/gdal/wiki/GdalOgrCsharpVersions
checkout the SVN trunk.
2. Download and extract the swigwin1.3.31 package
3. The following values should be set in nmake.opt (for the VC2005 builds)
SWIG = [path to swig]\swig.exe
MSVC_VER=1400
4 .You should compile the gdal core before compiling the csharp interface
C:\GDAL> nmake /f makefile.vc
5. C#
C:\GDAL\swig\csharp> nmake /f makefile.vc interface
C:\GDAL\swig\csharp> nmake /f makefile.vc
6. Add the gdal root directory in the the PATH (alternatively you can
copy gdal14.dll and proj.dll to the swig\csharp directory)
set PATH=C:\GDAL;%PATH%
7.
C:\GDAL\swig\csharp> nmake /f makefile.vc test
If you don't have any of the required dll-s (like proj) download the
recent FWTools package
http://test.gdal.org/fwtools/FWTools130.exe
Best regards,
Tamas
2007/5/24, Scott Schulthess <scott at topozone.com>:
>
>
>
>
> Hey, I'm having trouble following the directions on
>
>
>
> http://trac.osgeo.org/gdal/wiki/GdalOgrCsharpCompile
>
>
>
> This is the output I get I try to create the interface
>
> nmake /f makefile.vc interface
>
>
>
> Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
> cd const
>
> C:\GDAL\swig\swig.exe -csharp -namespace GDAL -dllimport
> gdal_gdalconst_
>
> wrap -o gdalconst_wrap.c ../../include/gdalconst.i
>
> cd ..
>
> cd gdal
>
> C:\GDAL\swig\swig.exe -c++ -csharp -namespace GDAL -dllimport
> gdal_gdal
>
> _wrap -I../../include/csharp -o gdal_wrap.cpp ../../include/gdal.i
>
> ..\..\include\Band.i(215): Warning(453): Can't apply (IF_ERROR_RETURN_NONE).
> No
>
> typemaps are defined.
>
> cd ..
>
> cd osr
>
> C:\GDAL\swig\swig.exe -c++ -csharp -namespace OSR -dllimport
> gdal_osr_w
>
> rap -I../../include/csharp -o osr_wrap.cpp ../../include/osr.i
>
> cd ..
>
> cd ogr
>
> C:\GDAL\swig\swig.exe -c++ -csharp -namespace OGR -dllimport
> gdal_osr_w
>
> rap -I../../include/csharp -o osr_wrap.cpp ../../include/osr.i
>
> C:\GDAL\swig\swig.exe -c++ -csharp -namespace OGR -dllimport
> gdal_ogr_wr
>
> ap -I../../include/csharp -o ogr_wrap.cpp ../../include/ogr.i
>
> cd ..
>
>
>
> Notice the Band.I warning.
>
>
>
> So then I ran nmake /f makefile.vc
>
>
> Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
> sn -k gdal.snk
>
>
>
> Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42
>
> Copyright (c) Microsoft Corporation. All rights reserved.
>
>
>
> Key pair written to gdal.snk
>
> cd ogr
>
> nmake /nologo /f makefile.vc
>
> cl /nologo /MD /EHsc /Zi /D_CRT_SECURE_NO_DEPRECATE
> /D_CRT_NONSTDC_NO_DE
>
> PRECATE /Fd..\..\..\gdal.pdb -I..\..\..\port -I..\..\..\ogr -I..\..\..\gcore
> -I
>
> ..\..\..\alg /c ogr_wrap.cpp
>
> ogr_wrap.cpp
>
> C:\unzipped\gdal141\gdal-1.4.1\port\cpl_port.h(86) : fatal error C1083:
> Cannot o
>
> pen include file: 'cpl_config.h': No such file or directory
>
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
> 8\VC\BIN\c
>
> l.EXE"' : return code '0x2'
>
> Stop.
>
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
> 8\VC\BIN\n
>
> make.EXE"' : return code '0x2'
>
> Stop.
>
>
>
> Well, within the prebuild library for windows
> (http://trac.osgeo.org/gdal/wiki/BuildingOnWindows) I found
> a cpl_config.h and moved it to /gdal/port
>
> directory
>
>
>
> Anyways now I get a bunch of the "unreachable expression code detected"
> about 50 times and the "no gdal_i.lib"
>
>
>
> osr\osr.cs(29,95): warning CS0429: Unreachable expression code detected
>
> osr\osr.cs(35,95): warning CS0429: Unreachable expression code detected
>
> osr\SpatialReference.cs(349,99): warning CS0429:
> Unreachable expression code
>
> detected
>
> link /dll /debug ogr_wrap.obj odbc32.lib odbccp32.lib
> user32.lib
>
> ..\..\gdal_i.lib /out:gdal_ogr_wrap.dll
>
> Microsoft (R) Incremental Linker Version 8.00.50727.42
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
> LINK : fatal error LNK1104: cannot open file '..\..\gdal_i.lib'
>
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
> 8\VC\BIN\l
>
> ink.EXE"' : return code '0x450'
>
> Stop.
>
>
>
> Well, there's a gdal_i.lib in those windows prebuild files I linked to
> above, so I moved that into the gdal root directory. No longer throws the
> gdal_i.lib file not found error, but still throws the "unreachable
> expression code detected' spam errors.
>
>
>
> Now I run the test nmake /f makefile.vc test
> and I get createdata.exe has an encountered a problem and needs to close.
>
>
>
> Unhandled Exception: System.TypeInitializationException:
> The type initializer fo
>
> r 'OGR.ogr' threw an exception. --->
> System.TypeInitializationException: The typ
>
> e initializer for 'OGR.ogrPINVOKE' threw an exception. --->
> System.TypeInitializ
>
> ationException: The type initializer for 'SWIGExceptionHelper' threw an
> exceptio
>
> n. ---> System.DllNotFoundException: Unable to load DLL 'gdal_ogr_wrap': The
> spe
>
> cified module could not be found. (Exception from HRESULT: 0x8007007E)
>
> at
> OGR.ogrPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_ogr(Exce
>
> ptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate,
> Excepti
>
> onDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate,
> Exce
>
> ptionDelegate invalidCastDelegate, ExceptionDelegate
> invalidOperationDelegate, E
>
> xceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate,
> ExceptionD
>
> elegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate,
> ExceptionDelega
>
> te systemExceptionDelegate)
>
> at OGR.ogrPINVOKE.SWIGExceptionHelper..cctor() in
> c:\unzipped\gdal141\gdal-1.
>
> 4.1\swig\csharp\ogr\ogrPINVOKE.cs:line 106
>
> --- End of inner exception stack trace ---
>
> at OGR.ogrPINVOKE.SWIGExceptionHelper..ctor()
>
> at OGR.ogrPINVOKE..cctor() in
> c:\unzipped\gdal141\gdal-1.4.1\swig\csharp\ogr\
>
> ogrPINVOKE.cs:line 126
>
> --- End of inner exception stack trace ---
>
> at OGR.ogrPINVOKE.wkb25Bit_get()
>
> at OGR.ogr..cctor() in
> c:\unzipped\gdal141\gdal-1.4.1\swig\csharp\ogr\ogr.cs:
>
> line 102
>
> --- End of inner exception stack trace ---
>
> at OGR.ogr.RegisterAll()
>
> at CreateData.Main(String[] args)
>
> NMAKE : fatal error U1077: '.\createdata.exe' : return code '0xe0434f4d'
>
> Stop.
>
>
>
> Please help.
>
>
>
> Thanks!
>
>
>
> -Scott
More information about the Gdal-dev
mailing list