2015-02-17 67 views
0

我想在我的Android應用程序使用libbacktrace,我不知道如何構建它... ...構建libbacktrace爲Android

現在我試圖建立由腳本的lib:

#!/bin/bash 
ndk-build \ 
    APP_BUILD_SCRIPT=libbacktrace/Android.mk \ 
    NDK_PROJECT_PATH=. \ 
    APP_STL=stlport_static \ 
    LOCAL_C_INCLUDES+=include \ 
    LOCAL_C_INCLUDES+=../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include \ 
    LOCAL_C_INCLUDES+=../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include/ \ 
    APP_PLATFORM=android-19 

,我有錯誤:

[armeabi] Compile++ thumb: backtrace <= BacktraceImpl.cpp 
libbacktrace/BacktraceImpl.cpp: In member function 'virtual std::string Backtrace::FormatFrameData(const backtrace_frame_data_t*)': 
libbacktrace/BacktraceImpl.cpp:117:48: error: expected ')' before 'PRIxPTR' 
    snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s (%s+%" PRIuPTR ")", 
               ^
libbacktrace/BacktraceImpl.cpp:119:58: error: conversion lacks type at end of format [-Werror=format=] 
       frame->func_name.c_str(), frame->func_offset); 
                 ^
libbacktrace/BacktraceImpl.cpp:119:58: error: too many arguments for format [-Werror=format-extra-args] 
libbacktrace/BacktraceImpl.cpp:121:48: error: expected ')' before 'PRIxPTR' 
    snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s (%s)", frame->num, 
               ^
libbacktrace/BacktraceImpl.cpp:122:87: error: conversion lacks type at end of format [-Werror=format=] 
       (int)sizeof(uintptr_t)*2, relative_pc, map_name, frame->func_name.c_str()); 
                        ^
libbacktrace/BacktraceImpl.cpp:122:87: error: too many arguments for format [-Werror=format-extra-args] 
libbacktrace/BacktraceImpl.cpp:124:48: error: expected ')' before 'PRIxPTR' 
    snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s", frame->num, 
               ^
libbacktrace/BacktraceImpl.cpp:125:61: error: conversion lacks type at end of format [-Werror=format=] 
       (int)sizeof(uintptr_t)*2, relative_pc, map_name); 
                  ^
libbacktrace/BacktraceImpl.cpp:125:61: error: too many arguments for format [-Werror=format-extra-args] 
cc1plus: all warnings being treated as errors 
make: *** [obj/local/armeabi/objs/backtrace/BacktraceImpl.o] Error 1 

我明白,我做錯了什麼,但我不知道是什麼...

回答

0

看起來PRIxPTR(它應該是一個宏)的定義有些問題。

IIRC類型是printf()格式的「主」字母,例如, i in %i,詳情請參閱printf格式規格。 (Oops ...它被正式稱爲說明符,並且還有一個可選的長度子標識符,但您看到該點,但M $稱它們爲「printf類型字段字符」)。

在C中,"a" "b"相同"ab",所以#define X "i"後的文本"%" X相當於"%i"