手機 - Blackberry Passport - 如何支援-std=c++11



首先查看c++0x_warning.h

$ cat ~/bbndk/target_10_3_1_995/qnx6/usr/include/c++/4.8.3/bits/c++0x_warning.h
  #error This file requires compiler and library support for the \
  ISO C++ 2011 standard. This support is currently experimental, and must be \
  enabled with the -std=c++11 or -std=gnu++11 compiler options.

眼尖的使用者應該有看到4.8.3這個版本吧!但是,為何使用-std=c++11時,編譯器還是提示unrecognized command line option '-std=c++11'呢?這是因為NDK裡面竟然藏有4.6.34.8.3這兩個版本,但是預設卻是使用4.6.3這個版本,使者者可以使用如下指令看一下:

$ ls -al ~/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc*
lrwxrwxrwx 1 steward steward 38 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc -> arm-unknown-nto-qnx8.0.0eabi-gcc-4.6.3
lrwxrwxrwx 1 steward steward 38 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-4.6.3 -> arm-unknown-nto-qnx8.0.0eabi-gcc-4.6.3
lrwxrwxrwx 1 steward steward 38 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-4.8.3 -> arm-unknown-nto-qnx8.0.0eabi-gcc-4.8.3
lrwxrwxrwx 1 steward steward 41 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-ar -> arm-unknown-nto-qnx8.0.0eabi-gcc-ar-4.8.3
lrwxrwxrwx 1 steward steward 41 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-ar-4.8.3 -> arm-unknown-nto-qnx8.0.0eabi-gcc-ar-4.8.3
lrwxrwxrwx 1 steward steward 41 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-nm -> arm-unknown-nto-qnx8.0.0eabi-gcc-nm-4.8.3
lrwxrwxrwx 1 steward steward 41 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-nm-4.8.3 -> arm-unknown-nto-qnx8.0.0eabi-gcc-nm-4.8.3
lrwxrwxrwx 1 steward steward 45 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-ranlib -> arm-unknown-nto-qnx8.0.0eabi-gcc-ranlib-4.8.3
lrwxrwxrwx 1 steward steward 45 Oct 31  2014 /home/steward/bbndk/host_10_3_1_12/linux/x86/usr/bin/ntoarmv7-gcc-ranlib-4.8.3 -> arm-unknown-nto-qnx8.0.0eabi-gcc-ranlib-4.8.3

因此,如要讓Blackberry NDK編譯器可以支援c++11,只要把所有指到4.6.3的symlink改成指到4.8.3即可,如下指令修改(For ARM):

$ cd ~/bbndk/host_10_3_1_12/linux/x86/usr/bin/
$ rm ntoarmv7-c++
$ rm ntoarmv7-cpp
$ rm ntoarmv7-g++
$ rm ntoarmv7-gcc
$ rm ntoarmv7-gcov

$ ln -s ntoarmv7-c++-4.8.3 ntoarmv7-c++
$ ln -s ntoarmv7-cpp-4.8.3 ntoarmv7-cpp
$ ln -s ntoarmv7-g++-4.8.3 ntoarmv7-g++
$ ln -s ntoarmv7-gcc-4.8.3 ntoarmv7-gcc
$ ln -s ntoarmv7-gcov-4.8.3 ntoarmv7-gcov