← All tasks
cppceres-solver/ceres-solver #945Not checked yet

undefined reference to `google::base::CheckOpMessageBuilder::NewString()'

envgap__ceres-solver__ceres-solver-945

Original GitHub issue ↗Opened 2023-01-22

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not checked yet.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

ceres-solver/ceres-solver #945 · read the original issue
Dear Authors:

        I found another possibility that can cause problem https://github.com/ceres-solver/ceres-solver/issues/291#issue-234908608. If you compile **Open3D** and **ceres** in **one** cpp file, it will cause `google::base::CheckOpMessageBuilder::NewString()` undefined error. It's a shame that I'm just a beginner at ceres -solver, but I can share my problem here to remind others of another possible cause of this error.

# Environment

Ubuntu 20.04

ceres 2.1.0

Open3D 0.16.0

CMake 3.25.0

gcc 9.4.0



# cpp file

```cpp

#include <iostream>

#include <opencv2/opencv.hpp>

#include <ceres/ceres.h>

#include <chrono>



using namespace std;

using namespace cv;



// 代价函数的计算模型

struct CURVE_FITTING_COST

{

    const double _x, _y;    // x,y数据



    CURVE_FITTING_COST(double x, double y) : _x(x), _y(y) {}

    // 残差的计算

    template <typename T>

    bool operator()(const T* const abc, T* residual) const     // 残差

    {

        residual[0] = T(_y) - ceres::exp(abc[0] * T(_x) * T(_x) + abc[1] * T(_x) + abc[2]); // y-exp(ax^2+bx+c)

        return true;

    }



};



int main( int argc, char** argv )

{

    double a = 1.0, b = 2.0, c = 1.0;           // 真实参数值

    int N = 100;                                // 数据点

    double w_sigma=1.0;                         // 噪声Sigma值

    RNG rng;                                    // OpenCV随机数产生器

    double abc[3] = {0, 0, 0};                  // abc参数的估计值



    vector<double> x_data, y_data;              // 数据



    cout << "generating data: " << endl;

    for(int i=0; i<N; i++)

    {

        double x = i / 100.0;

        double y = exp(a * x * x + b * x + c) + rng.gaussian(w_sigma);

        x_data.push_back(x);

        y_data.push_back(y);

        cout << x_data[i] << " " << y_data[i] << endl;

    }



    // 构建最小二乘问题

    ceres::Problem problem;

    for(int i=0; i<N; i++)

    {

        problem.AddResidualBlock(     // 向问题中添加误差项

                // 使用自动求导,模板参数:误差类型,输出维度,输入维度,维数要与前面struct中一致

                new ceres::AutoDiffCostFunction<CURVE_FITTING_COST, 1, 3>(

                        new CURVE_FITTING_COST(x_data[i], y_data[i])

                ),

                nullptr,            // 核函数,这里不使用,为空

                abc                 // 待估计参数

        );

    }



    // 配置求解器

    ceres::Solver::Options options;     // 这里有很多配置项可以填

    options.linear_solver_type = ceres::DENSE_QR;  // 增量方程如何求解

    options.minimizer_progress_to_stdout = false;   // 输出到cout



    ceres::Solver::Summary summary;                // 优化信息

    chrono::steady_clock::time_point t1 = chrono::steady_clock::now();

    ceres::Solve(options, &problem, &summary);  // 开始优化

    chrono::steady_clock::time_point t2 = chrono::steady_clock::now();

    chrono::duration<double> time_used = chrono::duration_cast<chrono::duration<double>>(t2-t1);

    cout << "solve time cost = " << time_used.count()<< " seconds. " << endl;



    // 输出结果

    cout << summary.BriefReport() << endl;

    cout << "estim
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy reproduction is generic install-only; match the actual issue failure before admission.