Ceres-solverで外部参照エラー

前提

C++を使用して、googleのCeres-solverを使った最適化プログラムの作成を行っています。
チュートリアル実施時に、外部参照エラーが19件発生しました。

発生している問題・エラーメッセージ

添付画像の通り、外部参照のエラーが発生しています。

一つ抜粋
LNK2019 未解決の外部シンボル "__declspec(dllimport) public: __cdecl google::LogMessageVoidify::LogMessageVoidify(void)" (_imp??0LogMessageVoidify@google@@QEAA@XZ) が関数 "void __cdecl ceres::internal::Take0thOrderPart<struct ceres::Jet<double,1>,double *>(int,struct ceres::Jet<double,1> const *,double *)" (??$Take0thOrderPart@U?$Jet@N$00@ceres@@PEAN@internal@ceres@@YAXHPEBU?$Jet@N$00@1@PEAN@Z) で参照されました ceres_test C:\Users\mcw.RS\source\repos\ceres_test\ceres_test\main.obj 1

該当のソースコード

VS2019 C++17 x64
ceres-solverは、Cmakeを使用してVS2019対応でソリューションを作成しビルド実施。

Ceres-solverは、下記リンクのWindows導入方法を元に導入しています。vcpkgは使っていません。
http://ceres-solver.org/installation.html

C++

#include "ceres/ceres.h"#include "glog/logging.h"using ceres::AutoDiffCostFunction;using ceres::CostFunction;using ceres::Problem;using ceres::Solve;using ceres::Solver;// A templated cost functor that implements the residual r = 10 -// x. The method operator() is templated so that we can then use an// automatic differentiation wrapper around it to generate its// derivatives.struct CostFunctor { template <typename T> bool operator()(const T* const x, T* residual) const { residual[0] = 10.0 - x[0]; return true; }};int main(int argc, char** argv) { google::InitGoogleLogging(argv[0]); // The variable to solve for with its initial value. It will be // mutated in place by the solver. double x = 0.5; const double initial_x = x; // Build the problem. Problem problem; // Set up the only cost function (also known as residual). This uses // auto-differentiation to obtain the derivative (jacobian). CostFunction* cost_function = new AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor); problem.AddResidualBlock(cost_function, nullptr, &x); // Run the solver! Solver::Options options; options.minimizer_progress_to_stdout = true; Solver::Summary summary; Solve(options, &problem, &summary); std::cout << summary.BriefReport() << "\n"; std::cout << "x : " << initial_x << " -> " << x << "\n"; return 0;}

試したこと

エラー内容からglogのdllが読み込めていないのかと思い、ビルドした時に出力されるファイルにglogd.dllという
dllを設置してみました。

補足情報(FW/ツールのバージョンなど)

Ceres-solverや個人ブログ等を参照しながら実施しています、
新規でC++ファイルを作成後、ceres.hなどをinclude出来ないことがあり、プロパティから追加のインクルードディレクトリへ追加して無理やり読み込ませています。

このようなツールの導入する際の基礎的な知識がなく
Cmakeでソリューション作成、ビルドを行った後に何をするべきなのかが分かっておりません。

そのため、ビルド前後で不適当な操作を実施しているかもしれないとも考えています。

抽象的で申し訳ありませんが、何卒よろしくお願いいたします。
不足情報ありましたら、教えていただけますと幸いです。

イメージ説明

コメントを投稿

0 コメント