第一讲(3)osgearth编译

前题条件
完成osg 3.0的编译
Step 1 下载osgEarth 2.1.1
https://github.com/gwaldron/osgearth/downloads------------》https://github.com/gwaldron/osgearth/releases/tag/osgearth-2.5

                          ------------》http://osgearth.org/
Step 2 下载gdal 1.8.1并编译
下载地址:http://trac.osgeo.org/gdal/wiki/DownloadSource
编译方法:
运行vcvar32.bat
在gdal1.8.1的当前目录运行nmake /f makefile.vc MSVC_VER=1600
nmake /f makefile.vc install
nmake /f makefile.vc devinstall
最终结果在c:\warmerda下
Step 3 下载geos 3.3.2 并编译
下载地址:http://trac.osgeo.org/geos/
编译方法:
运行vcvar32.bat
双击运行autogen.bat
nmake /f makefile.vc MSVC_VER=1600
最终结果在c:\warmerda下

Step 4 下载SQLite 3.7.10
下载地址 :http://www.sqlite.org/download.html
建立一个静态链接工程,加入sqlite3开头的三个文件
建立一个exe工程,加入shell.c
将静态结果更名为sqlited.lib和sqlite.lib,分别表示debug和release版本
Step5 下载libzip的编译结果
下载地址:http://files.cnblogs.com/eaglezhao/libzip(vs10).rar
Step6 下载zlib并编译
下载地址:http://www.winimage.com/zLibDll/minizip.html
进入contrib\vstudio\vc10目录,双击工程进行编译。
step7 下载并编译proj 4
下载地址:http://trac.osgeo.org/proj/
编译方法
运行vcvar32.bat
nmake /f makefile.vc install
nmake /f makefile.vc install-all
step 8 使用cmake编译osgEarth
step 9 测试编译结果

详细编译步骤:

(1)将来自step1 下载的osgearth源文件解压到"019.Earth\builder\code\osgearth2.1.1\src"

 (2)  将"019.Earth\builder\code\osg3.0\src"中3rdparty 拷贝到"019.Earth\builder\code\osgearth2.1.1”中

                                                                 创建“019.Earth\builder\code\osgearth2.1.1\vc”文件夹

(3)编译"geos" 编译方法与GDAL编译方法相似,

  将vcvar32.bat拖进cmd窗口中

      cd 进入到geos-3.3.2目录中

      autogen.bat     

  nmake /f makefile.vc MSVC_VER=1600     

      执行上述语句后

     ----------->如果是geos3.3.2版本将会报错"BufferOp.cpp<97> error c2668",新的版本不会报错

     -----------》所要修改的内容是BufferOp.cpp 97 行 std::log(10)改为 std::log(10.0)

  提示编译成功,结果文件存放在"geos-3.3.2\src"中  -->geos.dll

                          -->geos.lib

                          -->geos_c_i.lib

                          -->geos_i.lib

                          -->geos_c.dll

      将上述文件拷贝到"019.Earth\builder\runtime\geos3.3.2\bin“中

  将"geos-3.3.2\include"中文件拷贝到 "019.Earth\builder\runtime\geos3.3.2\include“中

     path 中添加 "builder->runtime->geos3.3.2->bin"

(4)编译SQLite 下载源文件(详细路径见step 4 )sqlite-amalgamation-3071000.zip

          a.     解压下载的压缩文件(shell.c    sqlite3.c   sqlite3.h   sqlite3ext.h)到"*\sqlite-amalgamation-3071000\"目录

          b.     需要建立两个工程,

      (b1)---------->VS2010->File->new->project->visual C++->win32 console application->Name( 输入 "sqlite" )->Location(输入"*\sqlite-amalgamation-3071000\")->点击"OK"->application settings选择"empty project" ->点击"Finish"

               (b2)"Solution 'sqlit/1project'"右键->Add"New Project"->win32 console application->Name( 输入 "shell" )->OK->"Application Settings"(选中"Empty project")->"Finish"

               (b3)修改"sqlite"项目类型:右键"Properties"->"Congiguration Properties"->"Configuration Type"(改为 "Static library(.lib)")->"Target Extension"(改为 ".lib")->点击"应用"            -----》注:debug release 两个版本都需要修改

               (b4)Build->Batch Build->   shell Debug Win32 ->Build

                                               shell Release Win32

                                               sqlite Debug Win32

                                               sqlite Debug Win32

               (b5)shell->"source files"->add->Existing Item->"*\sqlite-amalgamation-3071000\shell.c"

               (b6)sqlite->"source files"->add->Existing Item->"*\sqlite-amalgamation-3071000\sqlite3.c"

                             ->"*\sqlite-amalgamation-3071000\sqlite3.h"

                             ->"*\sqlite-amalgamation-3071000\sqlite3ext.h"

               (b7)重复b4步骤

               (b8)因为shell编译的时候需要链接到sqlite.lib,所以报错

              (b9)"\sqlite-amalgamation-3071000\(shell.c    sqlite3.c   sqlite3.h   sqlite3ext.h)"   四个文件全部都拷贝到   "019.Earth\builder\runtime\sqlite3\include“

            "*\sqlite-amalgamation-3071000\sqlite\Debug\sqlite.lib"   拷贝到  "019.Earth\builder\runtime\sqlite3\bin“中并重命名为"sqlited.lib"

                       "*\sqlite-amalgamation-3071000\sqlite\release\sqlite.lib"   拷贝到  "019.Earth\builder\runtime\sqlite3\bin“

                (b10)对shell工程进行链接:shell-》右键-》property pages->Linker->input->"Additional dependencies"->点击"Edit"---

          ->添加"019.Earth\builder\runtime\sqlite3\bin\sqlited.lib"(debug版)

                            ->添加"019.Earth\builder\runtime\sqlite3\bin\sqlite.lib"(release版)

      (b11)Build->Batch Build->   shell Debug Win32 ->Build

                                                        shell Release Win32

               (b12)进行shell工程生成的文件的拷贝:

        "*\sqlite-amalgamation-3071000\sqlite\Debug\shell.exe"   拷贝到  "019.Earth\builder\runtime\sqlite3\bin“中并重命名为"shelld.exe"

                      "*\sqlite-amalgamation-3071000\sqlite\Release\shell.exe"   拷贝到  "019.Earth\builder\runtime\sqlite3\bin“中

               (b13)设置环境变量

                       path添加"019.Earth\builder\runtime\sqlite3\bin“

 

(5)MiniZip的编译:a.zlib:第三方库中"3rdparty/lib"包括"zlib1.lib zlib1d.lib"

                         b.libzip:可以通过step5下载到编译好的vs2010的版本(libzip(vs10).rar),将其解压,

                           将解压后的"libzip\(bin include lib man)"四个全部的文件夹 放到“3rdparty”文件夹中

(6)proj 4的编译:a.通过step7进行下载,下载结果为"proj-4.7.0.zip",进行解压,解压后文件夹为"proj-4.7.0";

                       b.cd 到  文件夹"proj-4.7.0"中,方法同编译GDAL

          nmake /f makefile.vc  MSVC_VER=1600

                            nmake /f makefile.vc install

          nmake /f makefile.vc install-all

                    c.最后的编译结果存放在"C:\PROJ"

                          将"C:\PROJ"拷贝到“019.Earth\builder\runtime\”  并将“PROJ”文件夹重命名为“PROJ4”

                        d.将“019.Earth\builder\runtime\PROJ4\bin” 添加到 path目录

(7)编译osgearth:  a.点击"cmake"            “where is the source code”->"019.Earth\builder\code\osgearth2.1.1\src"

                                                         "where to build the binaries"->“019.Earth\builder\code\osgearth2.1.1\vc”

         b.点击"Configure"按钮, 选择"Advanced","Specify the generatro for this project " 对话框中选择"Visual Studio 10" "Use default native compilers" 后点击"Finish"  弹出错误“Error in configuration process,project files may be invalid” ,点击"OK"

                         c.修复相关错误:

                           CURL_INCLUDE_DIR->"019.Earth/builder/code/osgearth2.1.1/3rdparty/include"

                           CURL_LIBRARY->"019.Earth/builder/code/osgearth2.1.1/3rdparty/lib/curllib.lib"

                           CURL_LIBRARY_DEBUG->"019.Earth/builder/code/osgearth2.1.1/3rdparty/lib/curllibd.lib"        

                           GDAL_INCLUDE_DIR-> "019.Earth/builder/runtime/GDAL1.8.1/include"

                           GDAL_LIBRARY-> "019.Earth/builder/runtime/GDAL1.8.1/lib/gdal_i.lib"

                           GEOS_INCLUDE_DIR-> "019.Earth/builder/runtime/geos3.3.2/include"

                           GEOS_LIBRATY-> "019.Earth/builder/runtime/geos3.3.2/bin/geos.lib"

           GEOS_LIBRATY_DEBUG-> "019.Earth/builder/runtime/geos3.3.2/bin/geos_i.lib"  

                           LIBZIP_INCLUDE_DIR->"019.Earth/builder/code/osgearth2.1.1/3rdparty/include"

                           LIBZIP_LIBRARY->"019.Earth/builder/code/osgearth2.1.1/3rdparty/lib/zip.lib"

                           OSG_INCLUDE_DIR->"019.Earth/builder/runtime/osg3.0/include"

                           ZLIB_INCLUDE_DIR->"019.Earth/builder/code/osgearth2.1.1/3rdparty/include"

                           ZLIB_LIBRARY->"019.Earth/builder/code/osgearth2.1.1/3rdparty/lib/zlib1.lib"

                           SQLITE3_INCLUDE_DIR->"019.Earth/builder/runtime/sqlite3/include"

                           SQLITE3_LIBRARY->"019.Earth/builder/runtime/sqlite3/bin/sqlite.lib"

                           OSG_DIR->"019.Earth/builder/runtime/osg3.0"

                           OSG_GEN_INCLUDE_DIR->"019.Earth/builder/runtime/osg3.0"

                        再次点击"Configure" ,minizip报错(step6 zlib中可能包含minizip)

                        忽略minizip错误,再次点击"Configure",无错误,点击"Generate"

                        "generate"完成后,打开“019.Earth\builder\code\osgearth2.1.1\vc”文件夹,启动"OSGEARTH.sln"

                        "Build"->"Batch Build" : 构建"ALL_BUILD"   "Debug"  "Debug|Win32"

                     构建"ALL_BUILD"   "Release"  "Release|Win32"

                         点击"BUILD"

                        编译成功 124个全部完成,

                        进行环境变量配置.

                        将 “019.Earth\builder\code\osgearth2.1.1\”中3rdparty 文件夹 拷贝到  "019.Earth/builder/runtime/osgearth"中

                        然后将"019.Earth/builder/runtime/osgearth/3rdparty/bin"  路径添加到 path中

                        将 “019.Earth\builder\code\osgearth2.1.1\src\src”中所有文件 拷贝到  "019.Earth/builder/runtime/osgearth/include"中

                        将  “019.Earth\builder\code\osgearth2.1.1\vc\lib\release”中所有.lib .dll文件 拷贝到 "019.Earth/builder/runtime/osgearth/lib"中

                        将  “019.Earth\builder\code\osgearth2.1.1\vc\lib\debug”中所有.lib .dll文件 拷贝到 "019.Earth/builder/runtime/osgearth/lib"中

                        将  “019.Earth\builder\code\osgearth2.1.1\vc\bin\debug”中所有.exe文件 拷贝到 "019.Earth/builder/runtime/osgearth/bin"中

                        将  “019.Earth\builder\code\osgearth2.1.1\vc\bin\release”中所有.exe文件 拷贝到 "019.Earth/builder/runtime/osgearth/bin"中

                        将 "019.Earth/builder/runtime/osgearth/lib" 中所有.dll文件 拷贝到"019.Earth/builder/runtime/osgearth/bin"中

                        然后将"019.Earth/builder/runtime/osgearth/bin" 放入path中

                        将"019.Earth\builder\code\osgearth2.1.1\src" 中data文件夹和tests文件夹 拷贝到 "019.Earth/builder/runtime/osgearth“文件夹中

                        重启电脑(??设置环境变量后)

                        cd 进入到 "019.Earth/builder/runtime/osgearth/tests” 目录

                        cd osgearth_viewer boston_buildings.earth(存在于"019.Earth/builder/runtime/osgearth/tests文件夹中)

                        运行成功后 osgearth 编译完成 所有的bin目录都会被设置环境变量

                        

转载于:https://www.cnblogs.com/xiyatuyun/p/3988460.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值