2012-07-12 102 views
5

我想安裝提升1.5到Android根據this錯誤,同時編譯提升在Android

當我編譯時,我得到一個錯誤。以下是編譯錯誤的片段:

gcc.compile.c++ bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link- static/threading-multi/pthread/thread.o 
<command-line>: warning: "BOOST_FILESYSTEM_VERSION" redefined 
<command-line>: warning: this is the location of the previous definition 
In file included from ./boost/thread/thread.hpp:17, 
      from libs/thread/src/pthread/thread.cpp:11: 
./boost/thread/pthread/thread_data.hpp: In member function 'void boost::thread_attributes::set_stack_size(size_t)': 
./boost/thread/pthread/thread_data.hpp:42: error: 'PAGE_SIZE' was not declared in this scope 

"../../toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic --sysroot=../../platforms/android-9/arch-arm -mthumb -Os -fno-strict-aliasing -O2 -DNDEBUG -g -lstdc++ -I../../sources/cxx-stl/gnu-libstdc++/include -I../../sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -D__GLIBC__ -DBOOST_NO_INTRINSIC_WCHAR_T -DBOOST_FILESYSTEM_VERSION=2 -pthread -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link-static/threading-multi/pthread/thread.o" "libs/thread/src/pthread/thread.cpp" 

...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link-static/threading-multi/pthread/thread.o... 

我發現這個錯誤,我不明白......

./boost/thread/pthread/thread_data.hpp:42: error: 'PAGE_SIZE' was not declared in this scope。它說PAGE_SIZE沒有被宣佈,但我不知道這意味着什麼。當我試圖在代碼中查看特定位置時,我沒有找到PAGE_SIZE

回答

4

像這樣的編譯錯誤通常通過首先查看預處理輸出來解決。嘗試用-E替換-c並將foo.o更改爲foo.pp(或其他)並檢查foo.pp文件以查找錯誤(搜索set_stack_size)。

這是相關代碼:

 void set_stack_size(std::size_t size) BOOST_NOEXCEPT { 
      if (size==0) return; 
      std::size_t page_size = getpagesize(); 
#ifdef PTHREAD_STACK_MIN 
      if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN; 
#endif 
      size = ((size+page_size-1)/page_size)*page_size; 

getpagesize()擴展到一些東西,引用PAGE_SIZE。我非常肯定sysconf是最近得到頁面大小的正確方法(tm),但是提升維護者可能有很好的理由使用getpagesize()。無論如何,你可以通過-DPAGE_SIZE=2048編譯參數或者目標的頁面大小來避開這個特定的錯誤。要麼,要麼修補源代替使用sysconf(_SC_PAGESIZE)

+0

現在的工作 - 公關oblem is line ::: if(size -DPAGE_SIZE = 2048。我現在的問題是,將這種方式加入2048是一個很好的解決方案?並感謝你的回答。 – solti 2012-07-12 08:27:10

+1

這不是一個理想的解決方案,但它是足夠的(但只有當頁面大小真的是2048)。 – 2012-07-12 18:11:26

+0

嘿布萊恩,真的很感激你的回答..我安裝boost庫到boost1.5/android/lib。問題是我只得到幾個靜態庫的提升..我實際上需要所有的庫的提升,因爲我想安裝一個庫到Android取決於boost +(其他庫)。你覺得我應該怎麼做 ?? – solti 2012-07-15 18:25:23

7

1.50 boost,ndk-r8b有這個問題。

由於這個線程我設法得到它固定的以下變化:

文件boost /線程/ thread.hpp

// Fix for missing macro 
#define PAGE_SIZE sysconf(_SC_PAGESIZE) 

#include <boost/thread/pthread/thread_data.hpp> 

請注意,我還需要改變這種自1.50提升:

文件boost /庫/文件系統/ src目錄/ operations.cpp

# ifdef BOOST_POSIX_API 

    const fs::path dot_path("."); 
    const fs::path dot_dot_path(".."); 
# include <sys/types.h> 
# include <sys/stat.h> 
# if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(ANDROID) 
#  include <sys/statvfs.h> 
#  define BOOST_STATVFS statvfs 
#  define BOOST_STATVFS_F_FRSIZE vfs.f_frsize 
# elif defined (ANDROID) 
#  include <sys/vfs.h> 
#  define BOOST_STATVFS statfs 
#  define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>(vfs.f_bsize) 
# else 
#  ifdef __OpenBSD__ 
#  include <sys/param.h> 
#  endif 
#  include <sys/mount.h> 
#  define BOOST_STATVFS statfs 
#  define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>(vfs.f_bsize) 
# endif 
+0

爲記錄,這似乎是固定的NDK R8E – yano 2013-05-06 21:27:43