Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ceres built with miniglog but not linking with app #1025

Closed
sengineering2008 opened this issue Nov 7, 2023 · 1 comment
Closed

Ceres built with miniglog but not linking with app #1025

sengineering2008 opened this issue Nov 7, 2023 · 1 comment

Comments

@sengineering2008
Copy link

Hi @alexsmac

libceres.a and libceres_internal.a are generated and build on Xcode using the Clang LLVM toolchain for iOS. It uses the internal miniglog, however, there are link issues while building an iOS app to compute residuals.

google::LogMessage::stream(), referenced from:
void ceres::AngleAxisRotatePoint(double const*, double const*, double*) in BAFunctionCeresSolver.o
ceres::internal::NumericDiff<MyToolScalarCostFunctorForBundleAdjustment, (ceres::NumericDiffMethodType)0, 2, ceres::internal::ParameterDims<false, 3, 7>, 0, 3>::EvaluateJacobianForParameterBlock(MyToolScalarCostFunctorForBundleAdjustment const*, double const*, ceres::NumericDiffOptions const&, int, int, int, double**, double*) in BAFunctionCeresSolver.o
ceres::internal::NumericDiff<MyToolScalarCostFunctorForBundleAdjustment, (ceres::NumericDiffMethodType)0, 2, ceres::internal::ParameterDims<false, 3, 7>, 1, 7>::EvaluateJacobianForParameterBlock(MyToolScalarCostFunctorForBundleAdjustment const*, double const*, ceres::NumericDiffOptions const&, int, int, int, double**, double*) in BAFunctionCeresSolver.o

a) the Xcode generator log says : Building for iOS : Forcing use of miniglog and tool
b) otool output says logging.o object is created with libceres (static build)
c) I also tried building and linking miniglog separately as a static entity
d) Cmake version is 3.27.4 and iOS version is 17
e) the script in CMakeLists.txt file in internal/ceres does not install miniglog in the include directories
f) in the header search paths, both the public directories are included as per your post in #196 (comment)

if (MINIGLOG)

Force the miniglog headers to the front of the public include directories to protect against the case when the user has glog installed in a standard location (specifically the same as the Ceres install location) but compiled Ceres with MINIGLOG anyway. Otherwise: "glog/logging.h" in the public Ceres headers used in client code would match the installed version of glog, not the miniglog headers, and the client application would fail to link.

Note that this is an imperfect fix, as we cannot control the include
directories in client projects, and they could easily invert this ordering
themselves (intentionally or otherwise) and so break their build.

target_include_directories(ceres BEFORE PUBLIC
$&lt;BUILD_INTERFACE:${Ceres_SOURCE_DIR}/internal/ceres/miniglog>
$&lt;INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal/miniglog>

@sengineering2008
Copy link
Author

Resolved - successfully built for IOS (arm64).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant