与Hunter建立Android的增强
我的麻烦是以下内容。
与Hunter的CMake集成了一个提升:
include(cmake/HunterGate.cmake)
cmake_host_system_information(RESULT HUNTER_JOBS_NUMBER QUERY NUMBER_OF_LOGICAL_CORES)
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.0.tar.gz"
SHA1 "a3d7f4372b1dcd52faa6ff4a3bd5358e1d0e5efd"
LOCAL
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_COMPONENTS)
list(APPEND BOOST_COMPONENTS system program_options)
hunter_add_package(Boost COMPONENTS ${BOOST_COMPONENTS})
find_package(Boost CONFIG COMPONENTS ${BOOST_COMPONENTS})
我在Linux Ubuntu上为Android构建了我的项目,并使用以下参数构建我的项目:
config-android : _android
cd $< && cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_TOOLCHAIN_FILE=$(NDK)/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$(ABI) \
-DANDROID_PLATFORM=android-$(MINSDKVERSION) \
-DANDROID_TARGET=$(TARGET) \
..
如果我分配$ abi = armeabi-v7a,那么一切都很好。如我所见,提升是在以下配置上构建的:
[ 75%] Performing build step for 'Boost-system'
Performing configuration checks
- default address-model : 32-bit [1]
- default architecture : arm [1]
Building the Boost C++ Libraries.
但是,如果分配了任何其他接口,例如,$ abi = x86_64,我有一个错误:
ld: error: /home/vitali/.hunter/_Base/a3d7f43/0db57b3/73320e1/Install/lib/libboost_program_options-mt-a64.a(cmdline.o) is incompatible with elf_x86_64
我怀疑该错误的原因是亨特构建的boost不是为分配的阿比。如我所见,它显示出与ARM ABI相同的配置:
[ 75%] Performing build step for 'Boost-system'
Performing configuration checks
- default address-model : 32-bit [1]
- default architecture : arm [1]
Building the Boost C++ Libraries.
我的问题是:如何使Hunter为适当的ABI构建增强功能? 谢谢!
my troubles are the following.
A boost is integrated to my CMake with hunter:
include(cmake/HunterGate.cmake)
cmake_host_system_information(RESULT HUNTER_JOBS_NUMBER QUERY NUMBER_OF_LOGICAL_CORES)
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.0.tar.gz"
SHA1 "a3d7f4372b1dcd52faa6ff4a3bd5358e1d0e5efd"
LOCAL
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_COMPONENTS)
list(APPEND BOOST_COMPONENTS system program_options)
hunter_add_package(Boost COMPONENTS ${BOOST_COMPONENTS})
find_package(Boost CONFIG COMPONENTS ${BOOST_COMPONENTS})
I build my project on linux Ubuntu for android with the following parameters:
config-android : _android
cd lt; && cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_TOOLCHAIN_FILE=$(NDK)/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$(ABI) \
-DANDROID_PLATFORM=android-$(MINSDKVERSION) \
-DANDROID_TARGET=$(TARGET) \
..
If I assign $ABI=armeabi-v7a, everything is all right. As I see, the boost is built on the following configuration:
[ 75%] Performing build step for 'Boost-system'
Performing configuration checks
- default address-model : 32-bit [1]
- default architecture : arm [1]
Building the Boost C++ Libraries.
However, if assign any other interface, for example, $ABI=x86_64, I have an error:
ld: error: /home/vitali/.hunter/_Base/a3d7f43/0db57b3/73320e1/Install/lib/libboost_program_options-mt-a64.a(cmdline.o) is incompatible with elf_x86_64
I suspect the reason for that error is the hunter builds boost not for the assigned ABI. As I see, it shows the same configuration as it was for arm ABI:
[ 75%] Performing build step for 'Boost-system'
Performing configuration checks
- default address-model : 32-bit [1]
- default architecture : arm [1]
Building the Boost C++ Libraries.
My question is the following: how to make hunter to build boost for the appropriate ABI ?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了亨特的问题。很容易解决。创建(或添加到)文件 cmake/hunter/config.cmake 以下行传递其他cmake/ndk-toolchain参数以增强构建:
通常,您必须通过android_abi和android_platform。 Hunter运行了新的CMAKE流程来构建Boost,NDK工具链通过了Abi&amp;平台不是。因此,工具链不知道如何构建增强功能并默认构建它。结果,有许多链接错误。
I've met the same problem with Hunter. It's easy to solve. Create (or add to) file cmake/Hunter/config.cmake the following lines to pass additional cmake/ndk-toolchain parameters to boost build:
Generally, you have to pass ANDROID_ABI and ANDROID_PLATFORM. Hunter runs new cmake process to build boost, ndk toolchain is passed, abi & platform are not. So, toolchain does not know how to build boost and builds it by default. As result, there are many link errors.