Mobile icon indicating copy to clipboard operation
Mobile copied to clipboard

安装android版paddle,cmake提示错误

Open breaknormal1 opened this issue 7 years ago • 16 comments

按照文档Inference demo配置android,cmake提示下面的错误:

CMake Error at CMakeLists.txt:32 (project): The CMAKE_CXX_COMPILER:

/Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/aarch64-linux-android-g++

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:32 (project): The CMAKE_C_COMPILER:

/Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/aarch64-linux-android-gcc

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!

什么原因呢?是什么路径不对吗?还是缺少了哪一步?

breaknormal1 avatar Dec 27 '17 06:12 breaknormal1

您好,看cmake错误信息,应该是编译器/Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/aarch64-linux-android-g++不存在。请先确认一下。

编译inference demo,需要按照Android平台编译指南准备交叉编译环境小结中所述,生成独立工具链。

如果以上两点都确认没有问题,那请帖一下你所使用的CMake命令吧。

Xreki avatar Dec 27 '17 06:12 Xreki

你好, 在准备交叉编译环境小结中也提到cmake: cmake -DCMAKE_SYSTEM_NAME=Android
-DANDROID_STANDALONE_TOOLCHAIN=your/path/to/arm64_standalone_toolchain
-DANDROID_ABI=arm64-v8a
-DUSE_EIGEN_FOR_BLAS=OFF
-DCMAKE_INSTALL_PREFIX=your/path/to/install
-DWITH_C_API=ON
-DWITH_SWIG_PY=OFF
..

这里的 DCMAKE_INSTALL_PREFIX=your/path/to/install
是哪个路径呢?

breaknormal1 avatar Dec 27 '17 07:12 breaknormal1

@Xreki

breaknormal1 avatar Dec 27 '17 07:12 breaknormal1

Android平台编译指南这个文档里面,讲的是如何编译Android上用的Paddle库,CMake是在配置Paddle,CMAKE_INSTALL_PREFIX所指定的,是你希望Paddle库安装到的路径,也就是inference demo中的PADDLE_ROOT

inference demo里面的cmake命令,则是在配置这个demo本身。

Xreki avatar Dec 27 '17 07:12 Xreki

@Xreki Android平台编译指南参照这里的cmake: cmake -DCMAKE_SYSTEM_NAME=Android
-DANDROID_STANDALONE_TOOLCHAIN=/home/wyf/android-ndk-r14b/build/tools/arm64_standalone_toolchain
-DANDROID_ABI=arm64-v8a
-DUSE_EIGEN_FOR_BLAS=OFF
-DCMAKE_INSTALL_PREFIX=/home/wyf/paddle-android-demo
-DWITH_C_API=ON
-DWITH_SWIG_PY=OFF
.. 提示错误 CMake Error: The source directory "/home/wyf" does not appear to contain CMakeLists.txt.

是哪个路径不对吗?

breaknormal1 avatar Dec 27 '17 07:12 breaknormal1

这个是你执行cmake命令所在的目录不对。如果是编译Paddle,一般是按照如下命令:

$ git clone https://github.com/PaddlePaddle/Paddle.git
$ cd Paddle
$ mkdir build
$ cd build
$ cmake -DCMAKE_SYSTEM_NAME=Android 
-DANDROID_STANDALONE_TOOLCHAIN=/home/wyf/android-ndk-r14b/build/tools/arm64_standalone_toolchain 
-DANDROID_ABI=arm64-v8a 
-DUSE_EIGEN_FOR_BLAS=OFF 
-DCMAKE_INSTALL_PREFIX=/home/wyf/paddle-android-demo
-DWITH_C_API=ON 
-DWITH_SWIG_PY=OFF 
..

cmake最后的..代表源码所在目录,也就是Paddle源码所在的根目录。

Xreki avatar Dec 27 '17 07:12 Xreki

另外:

  • inference demo有中文使用文档https://github.com/PaddlePaddle/Mobile/blob/develop/benchmark/tool/C/README_cn.md 。
  • 可以不必亲自编译Paddle库,wiki页面提供了预编译好的版本:https://github.com/PaddlePaddle/Mobile/wiki

Xreki avatar Dec 27 '17 07:12 Xreki

好的,谢谢 “Android平台编译指南”的cmake可以编译了,我先按照文档“Inference demo”试一下,不行的话再用预编译好的Paddle

breaknormal1 avatar Dec 27 '17 08:12 breaknormal1

@Xreki 根据inference demo第一步完成,生成了一paddle-android-demo-DWITH_C_API=ON文件夹,这里面也出现了include/lib/third_party三个目录;但在进行第二步[Step 2,编译示例程序],我的cmake如下:

root@wyf-virtual-machine:/home/wyf/Mobile/benchmark/tool/C/build# cmake .. \
> -DANDROID_ABI=arm64-v8a \
> -DANDROID_STANDALONE_TOOLCHAIN=/Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain \
> -DPADDLE_ROOT=paddle-android-demo-DWITH_C_API=ON \
> -DCMAKE_BUILD_TYPE=MinSizeRel
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:32 (project):
  The CMAKE_CXX_COMPILER:

    /Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/aarch64-linux-android-g++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:32 (project):
  The CMAKE_C_COMPILER:

    /Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/aarch64-linux-android-gcc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/home/wyf/Mobile/benchmark/tool/C/CMakeFiles/CMakeOutput.log".
See also "/home/wyf/Mobile/benchmark/tool/C/CMakeFiles/CMakeError.log".

提示有问题。。。 在/Home/wyf/android-ndk-r14b/build/tools/arm64_standlone_toolchain/bin/目录下有aarch64-linux-android-g++ 和 aarch64-linux-android-gcc

breaknormal1 avatar Dec 27 '17 09:12 breaknormal1

这个看起来有点奇怪了,可以看下/home/wyf/Mobile/benchmark/tool/C/CMakeFiles/CMakeError.log有什么错误信息吗?

Xreki avatar Dec 27 '17 09:12 Xreki

@Xreki CMakeError.log 这是CMakeError.log,麻烦看一下

breaknormal1 avatar Dec 28 '17 01:12 breaknormal1

@Xreki hi,这个问题搞定了,谢谢你的提示。。。。

breaknormal1 avatar Dec 28 '17 06:12 breaknormal1

我上午看了下你的CMakeError.log,其实没看出来原因,:worried:

谢谢你对Paddle的支持,另外,我们有一个正在开发中的Android demo,前端开发工作还没完成,https://github.com/PaddlePaddle/Mobile/pull/61 ,这个demo的效果将和iOS demo https://github.com/PaddlePaddle/Mobile/blob/develop/Demo/iOS/AICamera/README_cn.md 一样。希望能给你提供些参考。

经过如下几个步骤,你即可运行该demo:

  • 下载该PR代码
$ cd Mobile
$ git fetch DemoAndroid
$ git checkout DemoAndroid
  • 从https://github.com/PaddlePaddle/Mobile/wiki 下载android的预编译库,解压后目录重命名为paddle-android放在Demo/Android/AICamera目录下
  • 从https://github.com/PaddlePaddle/Mobile/blob/develop/Demo/iOS/AICamera/README_cn.md#%E6%A8%A1%E5%9E%8B 下载模型,放到assets/models目录下

Xreki avatar Dec 28 '17 08:12 Xreki

@Xreki OK,期待你们的前端尽快搞定

breaknormal1 avatar Dec 29 '17 04:12 breaknormal1

@Xreki 再问一下,你上面说的“经过如下几个步骤,你即可运行该demo:”, 是你们Android demo做好之后,我就可以按照你说的步骤来,是这个意思吗?还是其他意思。。。。。

breaknormal1 avatar Dec 29 '17 08:12 breaknormal1

不是的,我的意思是, 我们的前端还没做好,但是当前版本也是可以运行的。如果你需要将Paddle集成到Android app里面,当前版本也可以提供一些参考。

Xreki avatar Dec 29 '17 08:12 Xreki