Windows环境下编译Ceres

2024-05-30 04:18
文章标签 编译 windows 环境 ceres

本文主要是介绍Windows环境下编译Ceres,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. 下载ceres稳定版本ceres-solver-1.14.0

2. 解压进入jni目录,修改Application.mk文件

#APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
#APP_PROJECT_PATH := $(call my-dir)APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -frtti
APP_OPTIM := release# Use libc++ from LLVM. It is a modern BSD licensed implementation of
# the standard C++ library.
APP_STL := gnustl_static
APP_ABI := arm64-v8a

3. 修改Android.mk文件

# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
#   this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
#   used to endorse or promote products derived from this software without
#   specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: settinger@google.com (Scott Ettinger)
#         keir@google.com (Keir Mierle)
#
# Builds Ceres for Android, using the standard toolchain (not
# standalone). It uses LLVM's libc++ as the standard library. It is a
# modern BSD licensed implementation of the standard c++ library. We
# do this to avoid any licensing issues that may arise from using
# GCC's libstdc++ which is licensed under GPL3.
#
# Building
# --------
#
# You will have to specify the environment EIGEN_PATH to point to the
# Eigen sources when building. For example:
#
#   EIGEN_PATH=/home/keir/src/eigen-3.0.5 ndk-build -j
#
# It is also possible to specify CERES_EXTRA_DEFINES, in case you need
# to pass more definitions to the C compiler.
#
# Using the library
# -----------------
# Copy the static library:
#
#   ../obj/local/armeabi-v7a/libceres.a
#
# into your own project, then link it into your binary in your
# Android.mk file.
#
# Reducing binary size
# --------------------
# This build includes the Schur specializations, which increase the
# size of the binary. If you don't need them for your application,
# consider adding:
#
#   -DCERES_RESTRICT_SCHUR_SPECIALIZATION
#
# to the LOCAL_CFLAGS variable below.
#
# Changing the logging library
# ----------------------------
# Ceres Solver ships with a replacement for glog that provides a
# simple and small implementation that builds on Android. However, if
# you wish to supply a header only version yourself, then you may
# define CERES_GLOG_DIR to point to it.LOCAL_PATH := $(call my-dir)# Ceres requires at least NDK version r9d to compile.
#ifneq ($(shell $(LOCAL_PATH)/assert_ndk_version.sh "r9d" $(NDK_ROOT)), true)
#  $(error Ceres requires NDK version r9d or greater)
#endif#EIGEN_PATH := $(EIGEN_PATH)
EIGEN_PATH := $(LOCAL_PATH)/../eigen
# Ceres requires Eigen to build.
ifndef EIGEN_PATH$(error Ceres requires Eigen; please invoke via EIGEN_PATH=... ndk-build)
endifCERES_INCLUDE_PATHS := $(CERES_EXTRA_INCLUDES)
CERES_INCLUDE_PATHS += $(LOCAL_PATH)/../internal
CERES_INCLUDE_PATHS += $(LOCAL_PATH)/../internal/ceres
CERES_INCLUDE_PATHS += $(LOCAL_PATH)/../include
CERES_INCLUDE_PATHS += $(LOCAL_PATH)/../config# Use the alternate glog implementation if provided by the user.
ifdef CERES_GLOG_DIRCERES_INCLUDE_PATHS += $(CERES_GLOG_DIR)
elseCERES_INCLUDE_PATHS += $(LOCAL_PATH)/../internal/ceres/miniglog
endif
CERES_SRC_PATH := ../internal/ceresinclude $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(CERES_INCLUDE_PATHS)
LOCAL_C_INCLUDES += $(EIGEN_PATH)LOCAL_CPP_EXTENSION := .cc
LOCAL_CFLAGS := $(CERES_EXTRA_DEFINES) \-DCERES_NO_LAPACK \-DCERES_NO_SUITESPARSE \-DCERES_NO_CXSPARSE \-DCERES_STD_UNORDERED_MAP \-std=gnu++11 \-DCERES_TR1_MEMORY_HEADER \-DCERES_TR1_SHARED_PTR# If the user did not enable threads in CERES_EXTRA_DEFINES, then add
# CERES_NO_THREADS.
#
# TODO(sameeragarwal): Update comments here and in the docs to
# demonstrate how OpenMP can be used by the user.
ifeq (,$(findstring CERES_HAVE_PTHREAD, $(LOCAL_CFLAGS)))LOCAL_CFLAGS += -DCERES_NO_THREADS
endifLOCAL_SRC_FILES := $(CERES_SRC_PATH)/array_utils.cc \$(CERES_SRC_PATH)/blas.cc \$(CERES_SRC_PATH)/block_evaluate_preparer.cc \$(CERES_SRC_PATH)/block_jacobian_writer.cc \$(CERES_SRC_PATH)/block_jacobi_preconditioner.cc \$(CERES_SRC_PATH)/block_random_access_dense_matrix.cc \$(CERES_SRC_PATH)/block_random_access_diagonal_matrix.cc \$(CERES_SRC_PATH)/block_random_access_matrix.cc \$(CERES_SRC_PATH)/block_random_access_sparse_matrix.cc \$(CERES_SRC_PATH)/block_sparse_matrix.cc \$(CERES_SRC_PATH)/block_structure.cc \$(CERES_SRC_PATH)/callbacks.cc \$(CERES_SRC_PATH)/canonical_views_clustering.cc \$(CERES_SRC_PATH)/cgnr_solver.cc \$(CERES_SRC_PATH)/compressed_row_jacobian_writer.cc \$(CERES_SRC_PATH)/compressed_row_sparse_matrix.cc \$(CERES_SRC_PATH)/conditioned_cost_function.cc \$(CERES_SRC_PATH)/conjugate_gradients_solver.cc \$(CERES_SRC_PATH)/context.cc \$(CERES_SRC_PATH)/context_impl.cc \$(CERES_SRC_PATH)/coordinate_descent_minimizer.cc \$(CERES_SRC_PATH)/corrector.cc \$(CERES_SRC_PATH)/covariance.cc \$(CERES_SRC_PATH)/covariance_impl.cc \$(CERES_SRC_PATH)/dense_normal_cholesky_solver.cc \$(CERES_SRC_PATH)/dense_qr_solver.cc \$(CERES_SRC_PATH)/dense_sparse_matrix.cc \$(CERES_SRC_PATH)/detect_structure.cc \$(CERES_SRC_PATH)/dogleg_strategy.cc \$(CERES_SRC_PATH)/dynamic_compressed_row_jacobian_writer.cc \$(CERES_SRC_PATH)/dynamic_compressed_row_sparse_matrix.cc \$(CERES_SRC_PATH)/dynamic_sparse_normal_cholesky_solver.cc \$(CERES_SRC_PATH)/eigensparse.cc \$(CERES_SRC_PATH)/evaluator.cc \$(CERES_SRC_PATH)/file.cc \$(CERES_SRC_PATH)/function_sample.cc \$(CERES_SRC_PATH)/gradient_checker.cc \$(CERES_SRC_PATH)/gradient_checking_cost_function.cc \$(CERES_SRC_PATH)/gradient_problem.cc \$(CERES_SRC_PATH)/gradient_problem_solver.cc \$(CERES_SRC_PATH)/is_close.cc \$(CERES_SRC_PATH)/implicit_schur_complement.cc \$(CERES_SRC_PATH)/inner_product_computer.cc \$(CERES_SRC_PATH)/iterative_schur_complement_solver.cc \$(CERES_SRC_PATH)/lapack.cc \$(CERES_SRC_PATH)/levenberg_marquardt_strategy.cc \$(CERES_SRC_PATH)/line_search.cc \$(CERES_SRC_PATH)/line_search_direction.cc \$(CERES_SRC_PATH)/line_search_minimizer.cc \$(CERES_SRC_PATH)/linear_least_squares_problems.cc \$(CERES_SRC_PATH)/linear_operator.cc \$(CERES_SRC_PATH)/line_search_preprocessor.cc \$(CERES_SRC_PATH)/linear_solver.cc \$(CERES_SRC_PATH)/local_parameterization.cc \$(CERES_SRC_PATH)/loss_function.cc \$(CERES_SRC_PATH)/low_rank_inverse_hessian.cc \$(CERES_SRC_PATH)/minimizer.cc \$(CERES_SRC_PATH)/normal_prior.cc \$(CERES_SRC_PATH)/parameter_block_ordering.cc \$(CERES_SRC_PATH)/partitioned_matrix_view.cc \$(CERES_SRC_PATH)/polynomial.cc \$(CERES_SRC_PATH)/preconditioner.cc \$(CERES_SRC_PATH)/preprocessor.cc \$(CERES_SRC_PATH)/problem.cc \$(CERES_SRC_PATH)/problem_impl.cc \$(CERES_SRC_PATH)/program.cc \$(CERES_SRC_PATH)/reorder_program.cc \$(CERES_SRC_PATH)/residual_block.cc \$(CERES_SRC_PATH)/residual_block_utils.cc \$(CERES_SRC_PATH)/schur_complement_solver.cc \$(CERES_SRC_PATH)/schur_eliminator.cc \$(CERES_SRC_PATH)/schur_jacobi_preconditioner.cc \$(CERES_SRC_PATH)/schur_templates.cc \$(CERES_SRC_PATH)/scratch_evaluate_preparer.cc \$(CERES_SRC_PATH)/single_linkage_clustering.cc \$(CERES_SRC_PATH)/solver.cc \$(CERES_SRC_PATH)/solver_utils.cc \$(CERES_SRC_PATH)/sparse_cholesky.cc \$(CERES_SRC_PATH)/sparse_matrix.cc \$(CERES_SRC_PATH)/sparse_normal_cholesky_solver.cc \$(CERES_SRC_PATH)/split.cc \$(CERES_SRC_PATH)/stringprintf.cc \$(CERES_SRC_PATH)/subset_preconditioner.cc \$(CERES_SRC_PATH)/suitesparse.cc \$(CERES_SRC_PATH)/thread_token_provider.cc \$(CERES_SRC_PATH)/triplet_sparse_matrix.cc \$(CERES_SRC_PATH)/trust_region_minimizer.cc \$(CERES_SRC_PATH)/trust_region_preprocessor.cc \$(CERES_SRC_PATH)/trust_region_step_evaluator.cc \$(CERES_SRC_PATH)/trust_region_strategy.cc \$(CERES_SRC_PATH)/types.cc \$(CERES_SRC_PATH)/visibility_based_preconditioner.cc \$(CERES_SRC_PATH)/visibility.cc \$(CERES_SRC_PATH)/wall_time.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_d_d_d.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_2_2.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_2_3.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_2_4.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_2_d.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_3_3.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_3_4.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_3_6.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_3_9.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_3_d.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_3.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_4.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_6.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_8.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_9.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_4_d.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_2_d_d.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_4_4_2.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_4_4_3.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_4_4_4.cc \$(CERES_SRC_PATH)/generated/schur_eliminator_4_4_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_d_d_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_2.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_3.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_4.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_3.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_4.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_6.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_9.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_3_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_3.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_4.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_6.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_8.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_9.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_4_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_d_d.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_2.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_3.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_4.cc \$(CERES_SRC_PATH)/generated/partitioned_matrix_view_4_4_d.ccifndef CERES_GLOG_DIR
LOCAL_SRC_FILES += $(CERES_SRC_PATH)/miniglog/glog/logging.cc
endifLOCAL_MODULE := ceres
include $(BUILD_STATIC_LIBRARY)

3. 下载Eigine并配置到Android.mk中,jni的上级目录运行ndk-build.bat

这篇关于Windows环境下编译Ceres的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1015553

相关文章

python项目环境切换的几种实现方式

《python项目环境切换的几种实现方式》本文主要介绍了python项目环境切换的几种实现方式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 如何在不同python项目中,安装不同的依赖2. 如何切换到不同项目的工作空间3.创建项目

C++多线程开发环境配置方法

《C++多线程开发环境配置方法》文章详细介绍了如何在Windows上安装MinGW-w64和VSCode,并配置环境变量和编译任务,使用VSCode创建一个C++多线程测试项目,并通过配置tasks.... 目录下载安装 MinGW-w64下载安装VS code创建测试项目配置编译任务创建 tasks.js

在C#中调用Windows防火墙界面的常见方式

《在C#中调用Windows防火墙界面的常见方式》在C#中调用Windows防火墙界面(基础设置或高级安全设置),可以使用进程启动(Process.Start)或Win32API来实现,所以本文给大家... 目录引言1. 直接启动防火墙界面(1) 打开基本防火墙设置(firewall.cpl)(2) 打开高

基于Python实现局域网内Windows桌面文件传输

《基于Python实现局域网内Windows桌面文件传输》这篇文章介绍了如何使用Python实现一个局域网文件传输系统,包括发送端和接收端的代码示例,发送端和接收端都需要在同一局域网内运行,并且确保防... 目录发送端代码 (sender.py)接收端代码 (receiver.py)图形界面版本 (可选)使

Java编译错误java.lang.NoSuchFieldError的解决方案详析

《Java编译错误java.lang.NoSuchFieldError的解决方案详析》java.lang.NoSuchFieldError是Java中的一种运行时错误,:本文主要介绍Java编译错... 目录前言解决方案1. 统一JDK版本环境2. 优化maven-compiler-plugin配置3. 清

GO语言中gox交叉编译的实现

《GO语言中gox交叉编译的实现》本文主要介绍了GO语言中gox交叉编译的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录一、安装二、使用三、遇到的问题1、开启CGO2、修改环境变量最近在工作中使用GO语言进行编码开发,因

一篇文章彻底搞懂macOS如何决定java环境

《一篇文章彻底搞懂macOS如何决定java环境》MacOS作为一个功能强大的操作系统,为开发者提供了丰富的开发工具和框架,下面:本文主要介绍macOS如何决定java环境的相关资料,文中通过代码... 目录方法一:使用 which命令方法二:使用 Java_home工具(Apple 官方推荐)那问题来了,

Nginx搭建前端本地预览环境的完整步骤教学

《Nginx搭建前端本地预览环境的完整步骤教学》这篇文章主要为大家详细介绍了Nginx搭建前端本地预览环境的完整步骤教学,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录项目目录结构核心配置文件:nginx.conf脚本化操作:nginx.shnpm 脚本集成总结:对前端的意义很多

Linux挂载linux/Windows共享目录实现方式

《Linux挂载linux/Windows共享目录实现方式》:本文主要介绍Linux挂载linux/Windows共享目录实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录文件共享协议linux环境作为服务端(NFS)在服务器端安装 NFS创建要共享的目录修改 NFS 配

基于Python开发Windows自动更新控制工具

《基于Python开发Windows自动更新控制工具》在当今数字化时代,操作系统更新已成为计算机维护的重要组成部分,本文介绍一款基于Python和PyQt5的Windows自动更新控制工具,有需要的可... 目录设计原理与技术实现系统架构概述数学建模工具界面完整代码实现技术深度分析多层级控制理论服务层控制注