[GDAL]编译64位GDAL1.10

环境VS2010,swigwin-2.0.11

1. 打开nmake.opt文件,找到SWIG=swig.exe这一句,假如没有将swig的目录添加到环境变量中,那么将这句后面的swig.exe修改为swig.exe的全路径,如D:\Program Files (x86)\swigwin-2.0.11\swig.exe。如果设置了环境变量,那么就不需要进行修改了。

2. nmake.opt文件,找到“#WIN64=YES”,将前面的“#”去掉,保存

3. 用x64兼容命令提示符,开始编译,进入GDAL根目录,依次输入

1 nmake -f makefile.vc
2 nmake -f makefile.vc install
3 nmake -f makefile.vc devinstall
4 nmake -f makefile.vc clean
5 nmake -f makefile.vc MSVC_VER=1600clean
6 nmake -f makefile.vc MSVC_VER=1600DEBUG=1

4. 编译C# Wapper

swig\csharp中的AssemblyInfo.cs中,将

[assembly: AllowPartiallyTrustedCallers]注释掉
[assembly: SecurityRules(SecurityRuleSet.Level1)]保留

保证方法为安全关键代码,这样可以访问本地代码。这样就解决了出现如下异常:

“安全透明方法“OSGeo.GDAL.Gdal.AllRegister()”尝试通过方法“OSGeo.GDAL.GdalPINVOKE.AllRegister()”调用本机代码失败。方法必须是安全关键的或安全可靠关键的,才能调用本机代码。”

编译方法:

  1. cd swig\csharp  
  2. #nmake /f makefile.vc interface     #这句话暂时不需要  
  3. nmake /f makefile.vc  
  4. nmake /f makefile.vc install  

5.参考文献

http://blog.csdn.net/liminlu0314/article/details/6945452 C#包装库的编译

http://www.cnblogs.com/mgen/archive/2011/10/21/2220277.html 安全关键

http://www.cnblogs.com/bigbigtree/archive/2011/11/20/2256434.html C++ GDAL DLL编译含64位

 

posted @ 2014-02-15 23:06  太一吾鱼水  阅读(1890)  评论(1编辑  收藏  举报