我尝试使用clang 3.8为Android NDK r14b构建boost 1.58。我让它与gcc正确地工作但是clang并不是这样。
通过运行以下命令(它是program_options lib上的一个示例):
"androidNDK/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++"
-c
-x c++
-std=c++11
--stdlib=libc++
-mthumb
-Os
-O2
-g
-Wno-unused-local-typedefs
-O3
-Wno-inline
-Wall
--sysroot=androidNDK/platforms/android-24/arch-arm
-I"androidNDK/sources/cxx-stl/llvm-libc++/include"
-D_GLIBCXX__PTHREADS
-D__arm__
-D_REENTRANT
-D__ANDROID__
-DANDROID
-pthread
-std=c++11
--stdlib=libc++
-mthumb
-fno-strict-aliasing
-DBOOST_ALL_NO_LIB=1
-DBOOST_TEST_NO_MAIN
-DNDEBUG
-D_HAS_EXCEPTIONS=0
-D_LITTLE_ENDIAN
-I"."
-o "bin.v2\libs\program_options\build\clang-linux-android\release\link-static\runtime-link-static\target-os-linux\threadapi-pthread\threading-multi\config_file.o" "libs\program_options\src\config_file.cpp"
但是我在signal.h文件中遇到了一些错误:
clang++.exe: warning: argument unused during compilation: '-mthumb'
clang++.exe: warning: argument unused during compilation: '-mthumb'
In file included from libs\program_options\src\config_file.cpp:8:
In file included from .\boost/program_options/config.hpp:10:
In file included from .\boost/config.hpp:57:
In file included from .\boost/config/platform/linux.hpp:74:
In file included from .\boost/config/posix_features.hpp:18:
In file included from androidNDK/platforms/android-24/arch-arm/usr/include\unistd.h:34:
In file included from androidNDK/platforms/android-24/arch-arm/usr/include\sys/select.h:35:
androidNDK/platforms/android-24/arch-arm/usr/include\signal.h:86:18: error: expected ';' at
end of declaration list
sighandler_t sa_handler;
^
androidNDK/platforms/android-24/arch-arm/usr/include\asm/signal.h:101:22: note: expanded
from macro 'sa_handler'
#define sa_handler _u._sa_handler
^
In file included from libs\program_options\src\config_file.cpp:8:
In file included from .\boost/program_options/config.hpp:10:
In file included from .\boost/config.hpp:57:
In file included from .\boost/config/platform/linux.hpp:74:
In file included from .\boost/config/posix_features.hpp:18:
In file included from androidNDK/platforms/android-24/arch-arm/usr/include\unistd.h:34:
In file included from androidNDK/platforms/android-24/arch-arm/usr/include\sys/select.h:35:
androidNDK/platforms/android-24/arch-arm/usr/include\signal.h:87:12: error: expected ')'
void (*sa_sigaction)(int, struct siginfo*, void*);
^
androidNDK/platforms/android-24/arch-arm/usr/include\asm/signal.h:102:24: note: expanded
from macro 'sa_sigaction'
#define sa_sigaction _u._sa_sigaction
^
androidNDK/platforms/android-24/arch-arm/usr/include\signal.h:87:10: note: to match this
'('
void (*sa_sigaction)(int, struct siginfo*, void*);
^
androidNDK/platforms/android-24/arch-arm/usr/include\signal.h:87:12: error: duplicate
member '_u'
void (*sa_sigaction)(int, struct siginfo*, void*);
^
androidNDK/platforms/android-24/arch-arm/usr/include\asm/signal.h:102:22: note: expanded
from macro 'sa_sigaction'
#define sa_sigaction _u._sa_sigaction
^
androidNDK/platforms/android-24/arch-arm/usr/include\signal.h:86:18: note: previous
declaration is here
sighandler_t sa_handler;
^
androidNDK/platforms/android-24/arch-arm/usr/include\asm/signal.h:101:20: note: expanded
from macro 'sa_handler'
#define sa_handler _u._sa_handler
^
3 errors generated.
有没有人做过这样的事情或者看错了什么?
答案 0 :(得分:0)
所以它最终对我有用。 我意识到signal.h上的那些错误是因为我的编译器的目标没有真正定义。我想为arm 32位构建boost,但是在"执行配置检查",它是: - 32位:不 - 64位:是的 - 手臂:是的
所以,我将我的boost文件夹中的user-config.jam更改为:
import os ;
androidNDKRoot = E:/androidNDK ; # put the relevant path
using clang : android :
$(androidNDKRoot)/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++ :
<compileflags>--sysroot=$(androidNDKRoot)/platforms/android-21/arch-arm
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(androidNDKRoot)/sources/android/support/include
<compileflags>-g
<compileflags>-Os
<compileflags>-O2
<compileflags>--target=armv7a-none-linux-androideabi
;
似乎clang没有和gcc一样的选项,所以我在PATH变量中添加了它们共同的绝对路径:
set PATH=%PATH%;E:\androidNDK\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\arm-linux-androideabi\bin\
为了测试构建(例如:atomic),我从我的boost文件夹执行:
b2.exe --user-config=tools\build\src\build\user-config.jam target-os=android toolset=clang-android link=static runtime-link=static variant=debug threading=multi -q -a -j6 --with-atomic