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

相关文章

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

SQLite3 在嵌入式C环境中存储音频/视频文件的最优方案

《SQLite3在嵌入式C环境中存储音频/视频文件的最优方案》本文探讨了SQLite3在嵌入式C环境中存储音视频文件的优化方案,推荐采用文件路径存储结合元数据管理,兼顾效率与资源限制,小文件可使用B... 目录SQLite3 在嵌入式C环境中存储音频/视频文件的专业方案一、存储策略选择1. 直接存储 vs

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4

Windows下C++使用SQLitede的操作过程

《Windows下C++使用SQLitede的操作过程》本文介绍了Windows下C++使用SQLite的安装配置、CppSQLite库封装优势、核心功能(如数据库连接、事务管理)、跨平台支持及性能优... 目录Windows下C++使用SQLite1、安装2、代码示例CppSQLite:C++轻松操作SQ

python常见环境管理工具超全解析

《python常见环境管理工具超全解析》在Python开发中,管理多个项目及其依赖项通常是一个挑战,下面:本文主要介绍python常见环境管理工具的相关资料,文中通过代码介绍的非常详细,需要的朋友... 目录1. conda2. pip3. uvuv 工具自动创建和管理环境的特点4. setup.py5.

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

Python中使用uv创建环境及原理举例详解

《Python中使用uv创建环境及原理举例详解》uv是Astral团队开发的高性能Python工具,整合包管理、虚拟环境、Python版本控制等功能,:本文主要介绍Python中使用uv创建环境及... 目录一、uv工具简介核心特点:二、安装uv1. 通过pip安装2. 通过脚本安装验证安装:配置镜像源(可

Windows的CMD窗口如何查看并杀死nginx进程

《Windows的CMD窗口如何查看并杀死nginx进程》:本文主要介绍Windows的CMD窗口如何查看并杀死nginx进程问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录Windows的CMD窗口查看并杀死nginx进程开启nginx查看nginx进程停止nginx服务

python获取cmd环境变量值的实现代码

《python获取cmd环境变量值的实现代码》:本文主要介绍在Python中获取命令行(cmd)环境变量的值,可以使用标准库中的os模块,需要的朋友可以参考下... 前言全局说明在执行py过程中,总要使用到系统环境变量一、说明1.1 环境:Windows 11 家庭版 24H2 26100.4061