亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

NDK編譯Boost(Cygwin環境)

系統 2317 0

  因為mapnik需要部分Boost模塊的支持,所以需要編譯Boost庫。Boost直接在Windows或者Linux下編譯并不難,幾條指令可以搞定,但是對于交叉編譯,正如本文將要闡述的使用NDK進行編譯,確實是比較頭疼。借助萬能的Google和Baidu,我將看到的方法做以整理并進行了親測。

  不過在這之前,我想闡明一個誤區,也是給自己補了個課。就是Boost庫在使用的時候,并不是都需要編譯的。有一小部分和平臺相關的模塊必須要編譯,大部分直接引用頭文件即可以使用。畢竟Boost太過龐大,全部編譯浪費時間,按需使用最佳。以下是從Boost官網摘錄的說明,在此不做翻譯了,這點單詞對碼農來說,不是事。

The only Boost libraries that must be built separately are:

A few libraries have optional separately-compiled binaries:

  • Boost.DateTime has a binary component that is only needed if you're using its to_string / from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland.
  • Boost.Graph also has a binary component that is only needed if you intend to parse GraphViz files .
  • Boost.Math has binary components for the TR1 and C99 cmath functions.
  • Boost.Random has a binary component which is only needed if you're using random_device .
  • Boost.Test can be used in “header-only” or “separately compiled” mode, although separate compilation is recommended for serious use .
  • Boost.Exception provides non-intrusive implementation of exception_ptr for 32-bit _MSC_VER==1310 and _MSC_VER==1400 which requires a separately-compiled binary. This is enabled by #define BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR.

  接下來介紹編譯步驟,我是在Windows下使用NDK編譯,所以選擇了Cygwin的環境,純Linux下方法大同小異。

  NDK版本:官方版 R10c

  Boost版本:1.57

  1、下載boost_1_57_0.tar.gz,將其放到Cygwin虛擬的Linux目錄下,比如/usr/。

  2、打開Cygwin,利用tar zxvf指令將boost_1_57_0.tar.gz解壓。

  3、cd到解壓后的Boost根目錄下,執行?./bootstrap.sh,生成boost編譯工具。

  4、用文本編輯器打開根目錄下的project-config.jam文件,修改為如下內容:

      
        import os ;

   

if [ os.name ] = CYGWIN || [ os.name ] = NT {  

    androidPlatform = windows ;  

    }  

    else if [ os.name ] = LINUX {  

    androidPlatform = linux-x86_64 ;  

    }  

    else if [ os.name ] = MACOSX {  

    androidPlatform = darwin-x86 ;  

    }  

 

ANDROID_NDK = 
        
          <
          
            實際的NDK
            
              路徑
              
                >
                
                   ; using gcc : android4.9 : $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ : 
                  
                    <
                    
                      archiver
                      
                        >
                        
                          $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar 
                          
                            <
                            
                              ranlib
                              
                                >
                                
                                  $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib 
                                  
                                    <
                                    
                                      compileflags
                                      
                                        >
                                        
                                          -I$(ANDROID_NDK)/platforms/android-19/arch-arm/usr/include 
                                          
                                            <
                                            
                                              compileflags
                                              
                                                >
                                                
                                                  -I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/include 
                                                  
                                                    <
                                                    
                                                      compileflags
                                                      
                                                        >
                                                        
                                                          -I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include 
                                                          
                                                            <
                                                            
                                                              compileflags
                                                              
                                                                >
                                                                
                                                                  -fexceptions 
                                                                  
                                                                    <
                                                                    
                                                                      compileflags
                                                                      
                                                                        >
                                                                        
                                                                          -frtti 
                                                                          
                                                                            <
                                                                            
                                                                              compileflags
                                                                              
                                                                                >
                                                                                
                                                                                  -fpic 
                                                                                  
                                                                                    <
                                                                                    
                                                                                      compileflags
                                                                                      
                                                                                        >
                                                                                        
                                                                                          -ffunction-sections 
                                                                                          
                                                                                            <
                                                                                            
                                                                                              compileflags
                                                                                              
                                                                                                >
                                                                                                
                                                                                                  -funwind-tables 
                                                                                                  
                                                                                                    <
                                                                                                    
                                                                                                      compileflags
                                                                                                      
                                                                                                        >
                                                                                                        
                                                                                                          -D__ARM_ARCH_5__ 
                                                                                                          
                                                                                                            <
                                                                                                            
                                                                                                              compileflags
                                                                                                              
                                                                                                                >
                                                                                                                
                                                                                                                  -D__ARM_ARCH_5T__ 
                                                                                                                  
                                                                                                                    <
                                                                                                                    
                                                                                                                      compileflags
                                                                                                                      
                                                                                                                        >
                                                                                                                        
                                                                                                                          -D__ARM_ARCH_5E__ 
                                                                                                                          
                                                                                                                            <
                                                                                                                            
                                                                                                                              compileflags
                                                                                                                              
                                                                                                                                >
                                                                                                                                
                                                                                                                                  -D__ARM_ARCH_5TE__ 
                                                                                                                                  
                                                                                                                                    <
                                                                                                                                    
                                                                                                                                      compileflags
                                                                                                                                      
                                                                                                                                        >
                                                                                                                                        
                                                                                                                                          -Wno-psabi 
                                                                                                                                          
                                                                                                                                            <
                                                                                                                                            
                                                                                                                                              compileflags
                                                                                                                                              
                                                                                                                                                >
                                                                                                                                                
                                                                                                                                                  -march=armv5te 
                                                                                                                                                  
                                                                                                                                                    <
                                                                                                                                                    
                                                                                                                                                      compileflags
                                                                                                                                                      
                                                                                                                                                        >
                                                                                                                                                        
                                                                                                                                                          -mtune=xscale 
                                                                                                                                                          
                                                                                                                                                            <
                                                                                                                                                            
                                                                                                                                                              compileflags
                                                                                                                                                              
                                                                                                                                                                >
                                                                                                                                                                
                                                                                                                                                                  -msoft-float 
                                                                                                                                                                  
                                                                                                                                                                    <
                                                                                                                                                                    
                                                                                                                                                                      compileflags
                                                                                                                                                                      
                                                                                                                                                                        >
                                                                                                                                                                        
                                                                                                                                                                          -mthumb 
                                                                                                                                                                          
                                                                                                                                                                            <
                                                                                                                                                                            
                                                                                                                                                                              compileflags
                                                                                                                                                                              
                                                                                                                                                                                >
                                                                                                                                                                                
                                                                                                                                                                                  -Os 
                                                                                                                                                                                  
                                                                                                                                                                                    <
                                                                                                                                                                                    
                                                                                                                                                                                      compileflags
                                                                                                                                                                                      
                                                                                                                                                                                        >
                                                                                                                                                                                        
                                                                                                                                                                                          -fomit-frame-pointer 
                                                                                                                                                                                          
                                                                                                                                                                                            <
                                                                                                                                                                                            
                                                                                                                                                                                              compileflags
                                                                                                                                                                                              
                                                                                                                                                                                                >
                                                                                                                                                                                                
                                                                                                                                                                                                  -fno-strict-aliasing 
                                                                                                                                                                                                  
                                                                                                                                                                                                    <
                                                                                                                                                                                                    
                                                                                                                                                                                                      compileflags
                                                                                                                                                                                                      
                                                                                                                                                                                                        >
                                                                                                                                                                                                        
                                                                                                                                                                                                          -finline-limit=64 
                                                                                                                                                                                                          
                                                                                                                                                                                                            <
                                                                                                                                                                                                            
                                                                                                                                                                                                              compileflags
                                                                                                                                                                                                              
                                                                                                                                                                                                                >
                                                                                                                                                                                                                
                                                                                                                                                                                                                  -Wa,--noexecstack 
                                                                                                                                                                                                                  
                                                                                                                                                                                                                    <
                                                                                                                                                                                                                    
                                                                                                                                                                                                                      compileflags
                                                                                                                                                                                                                      
                                                                                                                                                                                                                        >
                                                                                                                                                                                                                        
                                                                                                                                                                                                                          -DANDROID 
                                                                                                                                                                                                                          
                                                                                                                                                                                                                            <
                                                                                                                                                                                                                            
                                                                                                                                                                                                                              compileflags
                                                                                                                                                                                                                              
                                                                                                                                                                                                                                >
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                  -D__ANDROID__ 
                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                    <
                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                      compileflags
                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                        >
                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                          -DNDEBUG 
                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                            <
                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                              compileflags
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                >
                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                  -O2 
                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                    <
                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                      compileflags
                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                        >
                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                          -g ; project : default-build 
                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                            <
                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                              toolset
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                >
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                  gcc-android4.9 ; # List of --with-
                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                    <
                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                      library
                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                        > and --without-
                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                          <
                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                            library
                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                              >
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                 # options. If left empty, all libraries will be built. # Options specified on the command line completely # override this variable. libraries = --with-filesystem --with-thread --with-system --with-regex --with-program_options ;
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                
                                                                                                                                                                                                                              
                                                                                                                                                                                                                            
                                                                                                                                                                                                                          
                                                                                                                                                                                                                        
                                                                                                                                                                                                                      
                                                                                                                                                                                                                    
                                                                                                                                                                                                                  
                                                                                                                                                                                                                
                                                                                                                                                                                                              
                                                                                                                                                                                                            
                                                                                                                                                                                                          
                                                                                                                                                                                                        
                                                                                                                                                                                                      
                                                                                                                                                                                                    
                                                                                                                                                                                                  
                                                                                                                                                                                                
                                                                                                                                                                                              
                                                                                                                                                                                            
                                                                                                                                                                                          
                                                                                                                                                                                        
                                                                                                                                                                                      
                                                                                                                                                                                    
                                                                                                                                                                                  
                                                                                                                                                                                
                                                                                                                                                                              
                                                                                                                                                                            
                                                                                                                                                                          
                                                                                                                                                                        
                                                                                                                                                                      
                                                                                                                                                                    
                                                                                                                                                                  
                                                                                                                                                                
                                                                                                                                                              
                                                                                                                                                            
                                                                                                                                                          
                                                                                                                                                        
                                                                                                                                                      
                                                                                                                                                    
                                                                                                                                                  
                                                                                                                                                
                                                                                                                                              
                                                                                                                                            
                                                                                                                                          
                                                                                                                                        
                                                                                                                                      
                                                                                                                                    
                                                                                                                                  
                                                                                                                                
                                                                                                                              
                                                                                                                            
                                                                                                                          
                                                                                                                        
                                                                                                                      
                                                                                                                    
                                                                                                                  
                                                                                                                
                                                                                                              
                                                                                                            
                                                                                                          
                                                                                                        
                                                                                                      
                                                                                                    
                                                                                                  
                                                                                                
                                                                                              
                                                                                            
                                                                                          
                                                                                        
                                                                                      
                                                                                    
                                                                                  
                                                                                
                                                                              
                                                                            
                                                                          
                                                                        
                                                                      
                                                                    
                                                                  
                                                                
                                                              
                                                            
                                                          
                                                        
                                                      
                                                    
                                                  
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                              
                            
                          
                        
                      
                    
                  
                
              
            
          
        
      
    

  其中NDK路徑請根據實際情況填寫,另外gcc的版本也可以根據實際情況進行改動。libraries后面跟需要編寫的Boost模塊,需要哪個加哪個。

  Ps:此步驟和網上流傳的方法有一些出入,按照其說法是”?修改 boost/tools/build/v2/user-config.jam“,但實際Boost1.57中并沒有生成此文件,懷疑可能跟新版本中Boost修改了Bjam有關。

  5、執行./b2 toolset=gcc-android4.9 link=static threading=multi?target-os=linux --stagedir=android,--stagedir跟生成路徑。

?

  至此,就生成了編譯好的Boost模塊了。其中第四步的代碼是我綜合了網上的代碼和一個開源項目Boost for Android中的代碼,里面有很多編譯選項我也不是很懂,希望可以和大家交流。不過有一點可以保證,就是順利的編譯。

  順便吐槽下,mapnik確實是個很難配置的東西,我花了很長時間才讓它能用,因為需要太多的其他庫支持,特別是在Android上使用,需要交叉編譯。后面有空我會逐一整理出來,也希望有興趣的朋友一起交流。

?

?

NDK編譯Boost(Cygwin環境)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久激情五月 | 中文字幕在线免费观看视频 | 日韩国产成人资源精品视频 | 99久久一香蕉国产线看观看 | 2019最新四虎免费8848 | 97人人视频| 久久国产亚洲 | 亚洲热在线观看 | 亚洲午夜网 | 久久99精品一久久久久久 | 又黄又爽又成人免费视频 | 久久99中文字幕久久 | 草的我好爽的网站 | 欧美国产精品不卡在线观看 | 亚州一级毛片在线 | 国产成人精品区在线观看 | 国产一区二区三区久久 | 5388国产亚洲欧美在线观看 | 久久免费公开视频 | 久久影院中文字幕 | 日本激情视频一区二区三区 | 久久免费国产精品一区二区 | 久久一日本道色综合久久m 久久一色本道亚洲 | 国产福利午夜自产拍视频在线 | 奇米久久久 | 成人国产在线视频在线观看 | www.色五月| 久久久夜夜夜 | 成年女人午夜毛片免费看 | 波多野结衣一二三区 | 韩国19禁青草福利视频在线 | 中文字幕一区在线 | 亚洲视频手机在线 | 亚洲精品国产第一区二区图片 | 国产做国产爱免费视频 | 老司机午夜精品视频在线观看免费 | 色一色综合 | 亚洲国产天堂久久综合9999 | 91国在线视频 | 久久精品欧美一区二区 | 国内精品久久久久影院中国 |