Compiling PCL for android

Compiling PCL for android (in windows, cmake-gui)

I have been struggling with this for days.

 

According to the several tries in http://www.pcl-users.org/, there is no ‘official’ guide or package to compile it for android environment. Here is PCL wiki describing how to compile, but I think it’s outdated.

On the other hand, there is a build script called ‘pcl-superbuild‘, thanks to Pat Marion. Unfortunately, it is outdated too. However, it has been greatly helpful to understand cross compiling  and what should I need to compile PCL for compiling android successfully.

Since there seems no guide for windows environment with cmake-gui, I wrote this in simple steps for my sake. I compiled in windows x86, using cmake-gui(2.8.12).

 

 

Step 1. Run configuration with cmake-gui

Once run cmake-gui and configure, it will show a pop-up window to specify the generator. Choose compiler as MinGW Makefiles and check Specify toolchain file for cross-compiling.

cmake-gui_1

For toolchain, choose toolchain-android.cmake in ./toolchains.

Step 2. Setting correct paths / filepaths

During the configuration, errors may occur. Make sure the paths/filepaths are correct. In my case, all I had to do was setting PYTHON_EXECUTABLE and GIT_EXECUTABLE.

Step 3. Setting build target

After serveral times of fixing errors and re-configuring, you would have entries below. I checked BUILD_ANDROID only.

cmake-gui_2

When all entries are clear, then the output log would be like this:

cmake-gui_3

OK. Generate.

Step 4. Compile and troubleshooting

After this, you may want to build it. Go to where the generated makefiles are located, and run make. In my case, I run powershell and did like this (I will not explain options here):

cmake-gui_4

From here, you may have several errors depends on your environment. I’ll list what I have faced and resolved. Some can be resolved before run make; some may not, as you should clone dependencies prior to fix it.

TROUBLESHOOTING 1. PROBLEM WITH ‘ISNAN‘ OR ‘ISFINITE’

If you have a problem with these, it might be a confliction between C99 and C++11 support. Edit ./build/CMakeCache.txt and set below flags will fix it. Here’s a refer.

 

TROUBLESHOOTING 2. INTERNAL COMPILER ERROR AT ‘NARF.CPP’ AND ‘NARF_KEYPOINT.CPP’

There are several reports regard on this problem that using powf function will cause the 4.7 gcc of the Android NDK to crash. One workaround is changing powf to std::pow.

 

TROUBLESHOOTING 3. PTHREAD RELATED PROBLEM ON COMPILING BOOST LIBRARY

If there is some kind of #error “Sorry, no boost threads are available for this platform.” occurs, that probably be the conflict between boost and gcc 4.7. An old version of boost (1.45) is used here and in header file, it has no idea to proceed changed macro.

Add a flag in ./build/CMakeExternals/Source/boost/boost_1_45_0/boost/config/stdlib/libstdcpp3.hpp :

 

TROUBLESHOOTING 4. CMAKE ERROR – UNKOWN ARGUMENTS SPECIFIED

Got similar cases here, but not sure why. A variable is not matched maybe? Apparently, it relates to gcc version (in my case, gcc 4.7). The error prints like:

if given arguments:
“arm-linux-androideabi-gcc.exe (GCC) 4.7
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software”

From my experience, there were two places where this error occurs; GenerateExportHeader.cmake and vtkCompilerExtras.cmake. Both are in vtk’s cmake directory. Change those files

in GenerateExportHeader.cmake:

in vtkCompilerExtras.cmake:

Running in android

Copy Boost/Flann/Eigen/PCL static libraries in ./build/CMakeExternals/Install. I created android application with sample JNI project in Pat Marion’s PCL repository. With a little bit of modification, I could get a result below (output was pcd, I converted to ply to see in MeshLab):

PCL Point Cloud

 

Just one more thing. I was able to run it smoothly by changing Application.mk a bit, such as:

APP_PLATFORM := gnustl_static    (stlport_static won’t work)

C_FLAGS := -fpermissive -rtti            (these may fix Boost problem)

 

That’s it. As a future work, I need to find out how to compile with recent PCL library (1.7.1 now) and make a demo running in android device.


https://hcteq.wordpress.com/2014/07/14/compiling-pcl-for-android-in-windows-cmake-gui/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值