ceres-solver / ceres-solver

A large scale non-linear optimization library

Home Page:http://ceres-solver.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unresolved external symbol DynamicCostFunctionToFunctor

alan0526 opened this issue · comments

OS: Windows
Version: 2.2.0
IDE: Visual Studio 2022
Error Message:

1>calibration.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl ceres::DynamicCostFunctionToFunctor::~DynamicCostFunctionToFunctor(void)" (__imp_??1DynamicCostFunctionToFunctor@ceres@@QEAA@XZ)
1>calibration.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __cdecl ceres::DynamicCostFunctionToFunctor::operator()(double const * const *,double *)const " (__imp_??RDynamicCostFunctionToFunctor@ceres@@QEBA_NPEBQEBNPEAN@Z)
1>calibration.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl ceres::DynamicCostFunctionToFunctor::DynamicCostFunctionToFunctor(class ceres::CostFunction *)" (__imp_??0DynamicCostFunctionToFunctor@ceres@@QEAA@PEAVCostFunction@1@@Z)
1>D:\work\git_atg\ccm\ghj_calibration\ghj_calib\x64\Release\algo_test.exe : fatal error LNK1120: 3 unresolved externals

Screen Shots
DynamicCostFunctionToFunctor is not export
image
Solution2
option 1: remove CERES_EXPORT of the class
option 2: It could be: define the DynamicCostFunctionToFunctor constructor in .cc file

As a workaround, add the following code before including the ceres.h header. The CERES_EXPORT of DynamicCostFunctionToFunctor can be removed.

#ifndef CERES_STATIC_DEFINE
  #include "ceres/dynamic_cost_function.h"
  #undef CERES_EXPORT_H
  #define CERES_STATIC_DEFINE
  #include <ceres/dynamic_cost_function_to_functor.h>
  #undef CERES_STATIC_DEFINE
#else
  #include <ceres/ceres.h>
#endif