LNK2019 & LNK1120 Error



  • I have a little problem. that is LNK2019 & 1120 error.
    I added a class I created earlier.

    And I got this error.

    Important thing is this code is well build in VS2013 add-in.
    Whats wrong?
    I did not use the C ++ standard syntax?
    please help me..

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl MapBuilder::MapBuilder(void)" (??0MapBuilder@@QEAA@XZ) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)
    
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl MapBuilder::addNewNode(void)" (?addNewNode@MapBuilder@@QEAAXXZ) referenced in function "public: void __cdecl MainWindow::run(void)" (?run@MainWindow@@QEAAXXZ)
    
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: struct MapBuilder::Output_MapBuilder __cdecl MapBuilder::drawMap(void)" (?drawMap@MapBuilder@@QEAA?AUOutput_MapBuilder@1@XZ) referenced in function "public: void __cdecl MainWindow::run(void)" (?run@MainWindow@@QEAAXXZ)
    
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl MapBuilder::setOdo(double *,double *)" (?setOdo@MapBuilder@@QEAAXPEAN0@Z) referenced in function "public: void __cdecl MainWindow::run(void)" (?run@MainWindow@@QEAAXXZ)
    
    release\QNaviDemo.exe:-1: error: LNK1120: 4 unresolved externals
    

    *code MainWindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    //
    #include <commdialog.h>
    //
    #include <QPushButton>
    #include <QMessageBox>
    #include <QCheckBox>
    #include <QTextEdit>
    #include <QGroupBox>
    #include <QWidget>
    #include <QTimer>
    #include <QImage>
    #include <opencv2/opencv.hpp>
    //
    #include <mapbuilder.h>
    #include <imu.h>
    //
    #include <QDebug>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    public:
        CommDialog* m_CommDlg;
    
        QTextEdit* m_txtProcessing;
    
        QCheckBox* m_cStatus1;
        QCheckBox* m_cStatus2;
        QCheckBox* m_cStatus3;
    
        QLabel* m_disp1;
        QLabel* m_disp2;
    
        MapBuilder* m_mapBuilder;
        double* dist, *euler;
    	bool isFirst;
    
    	//tmp
    	double tmpDisX , tmpDisY ;
    	double sumDist;
    	void run();
    private:
        bool m_bConnected;
    
        //image processing
        cv::VideoCapture cap;
        cv::Mat m_matOrigin;
        cv::Mat m_matProcessed;
        QImage* m_qimgOrigin;
        QImage* m_qimgProcessed;
    
        QTimer* m_tmrTimer;
        QPushButton* m_btnPause;
    
    public slots:
        void processFrameAndUpdateGUI();
    private slots:
        void openCommDialog();
        void on_btnRun_clicked();
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    
    

    *code mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow),
    	tmpDisX(0), tmpDisY(0), sumDist(0)
    {
        ui->setupUi(this);
        /*********************************************
         ************** Main Widget ******************
         ********************************************/
        QWidget* main_Widget = new QWidget(this);
        this->setCentralWidget(main_Widget);
    
        /*********************************************
         ********** Main Layout & GroupBox ***********
         ********************************************/
        QGridLayout* mainLayout = new QGridLayout();
    
        QGroupBox* gboxVideo = new QGroupBox("Video");
        QGroupBox* gboxComm = new QGroupBox("Communication");
        QGroupBox* gboxStatus = new QGroupBox("Status");
    
        mainLayout->addWidget(gboxVideo, 0, 0, 1, 2);
        mainLayout->addWidget(gboxStatus, 1, 0);
        mainLayout->addWidget(gboxComm, 2, 0);
    
        main_Widget->setLayout(mainLayout);
    
    
        //////////// Image Layout
        QGridLayout* layout1 = new QGridLayout;
        QGroupBox* gboxVideo1 = new QGroupBox("Input1");
        QGroupBox* gboxVideo2 = new QGroupBox("Input2");
        QHBoxLayout* layout1_1 = new QHBoxLayout;
        QHBoxLayout* layout1_2 = new QHBoxLayout;
    
        m_disp1 = new QLabel;
        m_disp2 = new QLabel;
    
        layout1_1->addWidget(m_disp1);
        layout1_2->addWidget(m_disp2);
    
        m_btnPause = new QPushButton("Pause");
        /*m_cam = new WebCam;
        m_cam->initialize();
        m_cam->caputre();
    
        if(m_cam->isOpened()){
            tmrTimer = new QTimer(this);
            connect(tmrTimer, SIGNAL(timeout()), this, SLOT(processFrameAndUpdateGUI()));
            tmrTimer->start(20);
        }*/
        //
        cap.open(0);
        if(!cap.isOpened()){
            QMessageBox::critical(this, "Error", "Cam not accessed succesfully");
        }
        m_tmrTimer = new QTimer(this);
        m_tmrTimer->start(20);
    
        gboxVideo1->setLayout(layout1_1);
        gboxVideo2->setLayout(layout1_2);
        layout1->addWidget(gboxVideo1,0,0);
        layout1->addWidget(gboxVideo2,0,1);
        layout1->addWidget(m_btnPause);
        gboxVideo->setLayout(layout1);
    
        //////////// Status Layout
        QHBoxLayout* layout2 = new QHBoxLayout;
        m_txtProcessing = new QTextEdit("Processing");
        m_txtProcessing->setReadOnly(true);
        layout2->addWidget(m_txtProcessing);
    
        QVBoxLayout* layout3 = new QVBoxLayout;
        m_cStatus1 = new QCheckBox("IMU Comm connected");
        m_cStatus2 = new QCheckBox("Robot Comm connected");
        m_cStatus3 = new QCheckBox("Camera Comm connected");
        m_cStatus1->setCheckable(false);
        m_cStatus1->setChecked(false);
        m_cStatus2->setCheckable(false);
        m_cStatus2->setChecked(false);
        m_cStatus3->setCheckable(false);
        m_cStatus3->setChecked(false);
    
        layout3->addWidget(m_cStatus1);
        layout3->addWidget(m_cStatus2);
        layout3->addWidget(m_cStatus3);
    
        layout2->addLayout(layout3);
        gboxStatus->setLayout(layout2);
    
        //////////// Comm Layout
        QHBoxLayout* Hlayout = new QHBoxLayout;
        QLabel* label1 = new QLabel("Connect the Port: ");
        QPushButton* btnComm = new QPushButton("Serial Comm");
        Hlayout->addWidget(label1);
        Hlayout->addWidget(btnComm);
        gboxComm->setLayout(Hlayout);
    
        m_CommDlg = new CommDialog();
    
        //////////// build the map
        m_mapBuilder = new MapBuilder();
    	isFirst = true;
    
        //////////// SIGNAL n SLOT
        /// open the comm dialog
        QObject::connect(btnComm, SIGNAL(clicked(bool)), this, SLOT(openCommDialog()));
    
        /// on Timer
        QObject::connect(m_btnPause, SIGNAL(clicked(bool)), this, SLOT(on_btnRun_clicked()));
        QObject::connect(m_tmrTimer, SIGNAL(timeout()), this, SLOT(processFrameAndUpdateGUI()));
    }
    
    MainWindow::~MainWindow()
    {
        delete[] m_CommDlg;
        delete ui;
    }
    
    void MainWindow::openCommDialog()
    {
        //m_CommDlg = new CommDialog();
    
        m_CommDlg->setWindowTitle(QString::fromUtf8("Connect the Serial Port"));
        m_CommDlg->show();
    
        m_cStatus1->setChecked(m_CommDlg->isConnected());
    }
    
    void MainWindow::processFrameAndUpdateGUI()
    {
        cap.read(m_matOrigin);
        if(m_matOrigin.empty())
            return;
    
        cv::cvtColor(m_matOrigin, m_matProcessed, CV_BGR2GRAY);
        cv::cvtColor(m_matOrigin, m_matOrigin, CV_BGR2RGB);
        QImage qimgOrigin((uchar*)m_matOrigin.data, m_matOrigin.cols, m_matOrigin.rows, m_matOrigin.step, QImage::Format_RGB888);
        QImage qimgProcessed((uchar*)m_matProcessed.data, m_matProcessed.cols, m_matProcessed.rows, m_matProcessed.step, QImage::Format_Indexed8);
    
        m_disp1->setPixmap(QPixmap::fromImage(qimgOrigin));
        m_disp2->setPixmap(QPixmap::fromImage(qimgProcessed));
    
    	if (!m_CommDlg->isConnected())
            return;
    	
    	run();
    	
    	
        //qDebug() << euler[0] << ", " << euler[1] << ", " << euler[2];
    	
        
    }
    
    void MainWindow::on_btnRun_clicked()
    {
        if(m_tmrTimer->isActive()){
            m_tmrTimer->stop();
            m_btnPause->setText("resume");
        }
        else{
            m_tmrTimer->start(20);
            m_btnPause->setText("pause");
        }
    }
    
    void MainWindow::run()
    {
    	dist = m_CommDlg->m_IMU->getDis();
    	euler = m_CommDlg->m_IMU->getEuler();
    	
    	if (isFirst)
    	{
    		m_mapBuilder->setOdo(euler, dist);
    		isFirst = false;
    	}
    	sumDist += (double)std::sqrt((dist[0] - tmpDisX)*(dist[0] - tmpDisX) + (dist[1] - tmpDisY)*(dist[1] - tmpDisY));
    	if ((sumDist > 1.0f) && !isFirst)
    	{
    		sumDist = 0;
    		m_mapBuilder->addNewNode();
    	}
    	tmpDisX = dist[0];
    	tmpDisY = dist[1];
    
    	
    	m_mapBuilder->drawMap();
    	m_mapBuilder->input.world_map_draw = 1;
    }
    

    *code MapBuilder.h

    #ifndef MAPBUILDER_H
    #define MAPBUILDER_H
    
    //#include <iostream>
    //#include <algorithm>
    #include <fstream>
    #include <opencv2/opencv.hpp>
    
    using namespace cv;
    using namespace std;
    
    struct Odo
    {
        Odo(double x_, double y_, double th_)
        {
            x = x_, y = y_, th = th_;
        };
        Odo()
        {
            x = 0, y = 0, th = 0;
        };
        double x;
        double y;
        double th;
    };
    struct Localization_Info
    {
        int idx = 0;
        float bel = 0;
    };
    struct Input
    {
        bool world_map_draw = 0;
    };
    struct Output_MapBuilder
    {
        cv::Mat map;
        cv::Mat world_map;
        float world_map_resize_rate;
    
        cv::Mat path_on_img;
        cv::Mat path_on_real;
    
        Odo center_on_img;
        float  col_range_on_img[2];
        float  row_range_on_img[2];
        cv::Mat angle2center;
    
        cv::Mat motion_distribution;
        cv::Mat edge_distance;
    
        cv::Mat reference_Path;
    
        int closest_node_idx;
        float closest_node_dist;
    
        int mouse_pointing_idx = 0;
        int mouse_chlick_flag = 0;
    };
    struct Node_state
    {
        int node_idx;
    
        std::vector<int> path_on;
    
        std::vector<int> img_edge_in;
        std::vector<Odo> relative_odo_edge_in;
    
        std::vector<int> img_edge_out;
        std::vector<Odo> relative_odo_edge_out;
    };
    
    class MapBuilder
    {
    public:
        MapBuilder();
        MapBuilder(double *euler, double *dist);    
    
        int last_localized_idx = 0;
        int last_localized_on_path_idx = 0;
        Odo last_localized_odo;
        Odo diff_from_node_robot;
        Odo now_robot_odo;
    
        //
        double* euler;
        double* dist;
        //MouseInterface mouse;
        Localization_Info localization;
        Input input;
        Output_MapBuilder output;
        std::map<int, Node_state> Node;
    
        void initialize(void);
        void setRobot(double *input_data);
    
        void addEdge(int from, int to, Odo from_odo, Odo to_odo);
        void addNewNode(void);
        Odo addmotion(Odo base, Odo motion);
        Odo subtractmotion(Odo base, Odo motion);
        void getMinMaxImgSize(Output_MapBuilder *result_output, Odo *input);
        void getMotionCost(int now_idx, int last_idx, Output_MapBuilder *output);
        void get180Th(double *input);
        double getGapTh(double from, double to);
        void getEdgeDistance(cv::Mat *distacne, std::map<int, Node_state>::iterator base_node, int way);
        int getPath(int from, int to, Output_MapBuilder *output_prt);
        void Odo2col(cv::Mat *col, Odo *odo);
        void Col2odo(Odo *odo, cv::Mat *col);
        Odo getMotion(Odo from, Odo to);
        void pathConstructor(Output_MapBuilder *result_output, Odo base_odo
            , std::map<int, Node_state>::iterator base_node, float *path_cost);
    
        Odo Motion_filter(Odo *base, Odo *now, const Localization_Info *observation);
        Odo getmm2pixel(Odo *input);
    
        void updateRobotPose(Localization_Info *input);
        void updateLocalizetion(int idx, float bel, bool pose_initialize);
        void drawRobot(Odo robot_pose, cv::Mat *worldMap, cv::Scalar robot_color, double arrow_size);
        Output_MapBuilder drawMap(void);
        void saveNode(char *db_path);
        void loadNode(char *db_path);
    
        // set odo
        void setOdo(double* euler, double* dist);
    private:
        double *RobotPrt;
    
        double D2R, R2D; //degree to radian, radian to degree
        double MM2P, P2MM; // millimeter to pixel
        int map_row, map_col;
    
    
    };
    
    #endif // MAPBUILDER_H
    
    

    *code MapBuilder.cpp

    MapBuilder::MapBuilder()
    {
        initialize();
    }
    
    void MapBuilder::addNewNode(void)
    {
        //now_robot_odo.x = RobotPrt->getX();
        //now_robot_odo.y = RobotPrt->getY();
        //now_robot_odo.th = RobotPrt->getTh();
    
        if (Node.size() == 0)
        {
            Node_state fisrt_node;
            fisrt_node.node_idx = 1;
            Node.insert(pair<int, Node_state>(1, fisrt_node));
            last_localized_idx = 1;
            last_localized_odo = now_robot_odo;
            return;
        }
        std::map<int, Node_state>::iterator base = Node.find(last_localized_idx);
        if (base == Node.end())
        {
            std::printf("Error in addNewNode. Cannot find last_localized_idx node : %d\n", last_localized_idx);
            return;
        }
        int new_node_idx = (int)Node.size() + 1;
        Node_state new_node;
    
        new_node.node_idx = new_node_idx;
        Node.insert(std::pair<int, Node_state>(new_node_idx, new_node));
    
        addEdge(last_localized_idx, new_node_idx, last_localized_odo, now_robot_odo);
    
        last_localized_odo = now_robot_odo;
        last_localized_idx = new_node_idx;
    
        return;
    }
    Output_MapBuilder MapBuilder::drawMap(void)
    {
        int world_map_draw = input.world_map_draw;
    
        int size = (int)Node.size() + 1;
    
        output.map = cv::Mat(map_row, map_col, CV_8UC3, cv::Scalar(255, 255, 255));
        output.world_map = cv::Mat(map_row, map_col, CV_8UC3, cv::Scalar(255, 255, 255));
        output.motion_distribution = cv::Mat(1, size, CV_32FC1, cv::Scalar(0));
        output.edge_distance = cv::Mat(1, size, CV_32FC1, cv::Scalar(0));
        output.path_on_img = cv::Mat(3, size, CV_32FC1, cv::Scalar(0));
        output.path_on_real = cv::Mat(3, size, CV_32FC1, cv::Scalar(0));
        output.center_on_img.x = 0, output.center_on_img.y = 0, output.center_on_img.th = 0;
        output.col_range_on_img[0] = 0; output.col_range_on_img[1] = 1;
        output.row_range_on_img[0] = 0; output.row_range_on_img[1] = 1;
        output.angle2center = cv::Mat(1, size, CV_32FC1, cv::Scalar(0));
        output.world_map_resize_rate = 1.0f;
    
        now_robot_odo = Odo(dist[0], dist[1], euler[2]);
    
        if (Node.size() == 0)
        {
            return output;
        }
        if (last_localized_idx == 0)
        {
            last_localized_idx = 1;
        }
    
    
        Odo filtered_motion = Motion_filter(&last_localized_odo, &now_robot_odo, &localization);
        Odo filtered_motion_on_img = getmm2pixel(&filtered_motion);
    
        Odo2col(&output.path_on_img.col(last_localized_idx), &filtered_motion_on_img);
        Odo2col(&output.path_on_real.col(last_localized_idx), &filtered_motion);
        //float first_dist = sqrt(filtered_motion.x*filtered_motion.x + filtered_motion.y*filtered_motion.y);
        float first_dist = 1.0f;
    
        float *distance = new float[size];
        std::memset(distance, 0, sizeof(float)*size);
        distance[last_localized_idx] = first_dist;
    
        std::map<int, Node_state>::iterator base_node = Node.find(last_localized_idx);
        if (base_node == Node.end())
        {
            printf("Error in drawMap. last_localized_idx : %d\n", last_localized_idx);
            return output;
        }
    
        //main recursive function
        pathConstructor(&output, filtered_motion, base_node, distance);
        std::memcpy(output.edge_distance.data, distance, sizeof(float)*size);
    
        std::map<int, Node_state>::iterator drawer = Node.begin();
    
        Odo robot_pose;
        robot_pose.x = output.map.cols / 2.0;
        robot_pose.y = output.map.rows / 2.0;
        robot_pose.th = 0.0;
        output.closest_node_dist = 999999.f;
        output.closest_node_idx = 0;
        cv::Point closest_pose;
        int number_of_valid_node = 0;
    
        output.col_range_on_img[0] = robot_pose.x - 1; output.col_range_on_img[1] = robot_pose.x + 1;
        output.row_range_on_img[0] = robot_pose.y - 1; output.row_range_on_img[1] = robot_pose.y + 1;
    
        for (; drawer != Node.end(); drawer++)
        {
            int base_idx = drawer->second.node_idx;
            cv::Point base_pose
                = cv::Point(robot_pose.x - output.path_on_img.at<float>(1, base_idx), robot_pose.y - output.path_on_img.at<float>(0, base_idx));
    
            int edge_out_size = (int)drawer->second.img_edge_out.size();
            int edge_in_size = (int)drawer->second.img_edge_in.size();
            if (edge_out_size == 0 && edge_in_size == 0)
                continue;
    
            number_of_valid_node++;
    
            for (int edge_i = 0; edge_i < edge_out_size; edge_i++)
            {
                int out_idx = drawer->second.img_edge_out.at(edge_i);
                std::map<int, Node_state>::iterator edge_out = Node.find(out_idx);
                if (edge_out == Node.end())
                    continue;
                cv::Point out_pose
                    = cv::Point(robot_pose.x - output.path_on_img.at<float>(1, out_idx), robot_pose.y - output.path_on_img.at<float>(0, out_idx));
    
                cv::line(output.map, base_pose, out_pose, cv::Scalar(0, 0, 0), 1);
            }
    
            Odo node_odo;
            node_odo.x = robot_pose.x - output.path_on_img.at<float>(1, base_idx);
            node_odo.y = robot_pose.y - output.path_on_img.at<float>(0, base_idx);
            node_odo.th = output.path_on_img.at<float>(2, base_idx);
    
            output.center_on_img.x += node_odo.x;
            output.center_on_img.y += node_odo.y;
            output.center_on_img.th += node_odo.th;
            getMinMaxImgSize(&output, &node_odo);
    
            if (base_idx == last_localized_idx)
                drawRobot(node_odo, &output.map, cv::Scalar(200, 255, 200), 10);
            else
                drawRobot(node_odo, &output.map, cv::Scalar(255, 200, 200), 10);
    
            getMotionCost(base_idx, last_localized_idx, &output);
    
            float dist_from_robot = sqrt(output.path_on_real.at<float>(0, base_idx)*output.path_on_real.at<float>(0, base_idx)
                + output.path_on_real.at<float>(1, base_idx)*output.path_on_real.at<float>(1, base_idx));
            if (dist_from_robot < output.closest_node_dist)
            {
                output.closest_node_dist = dist_from_robot;
                output.closest_node_idx = base_idx;
                closest_pose = cv::Point(robot_pose.x - output.path_on_img.at<float>(1, base_idx), robot_pose.y - output.path_on_img.at<float>(0, base_idx));
            }
        }
        drawRobot(robot_pose, &output.map, cv::Scalar(255, 0, 0));
        cv::circle(output.map, closest_pose, 15, cv::Scalar(255, 0, 0));
    
        if (number_of_valid_node != 0)
        {
            output.center_on_img.x /= number_of_valid_node;
            output.center_on_img.y /= number_of_valid_node;
            output.center_on_img.th /= number_of_valid_node;
        }
    
        if (world_map_draw)
        {
            int closest_node_idx = 0;
            double closest_node_dist = 99999.0;
    
            double x_min = output.col_range_on_img[0] - output.center_on_img.x;
            double x_max = output.col_range_on_img[1] - output.center_on_img.x;
            double y_min = output.row_range_on_img[0] - output.center_on_img.y;
            double y_max = output.row_range_on_img[1] - output.center_on_img.y;
    
            float cols_size = 2.0f*(float)max(abs(x_min), abs(x_max));
            float rows_size = 2.0f*(float)max(abs(y_min), abs(y_max));
            float cols_rate = (float)(output.world_map.cols - 50) / cols_size;
            float rows_rate = (float)(output.world_map.rows - 50) / rows_size;
            float img_rate = min(cols_rate, rows_rate);
            img_rate = min(img_rate, 5.0f);
            output.world_map_resize_rate = img_rate;
    
            std::map<int, Node_state>::iterator world_drawer = Node.begin();
    
            cv::line(output.world_map, cv::Point(0, output.world_map.rows / 2), cv::Point(output.world_map.cols, output.world_map.rows / 2), cv::Scalar(0, 0, 255));
            cv::line(output.world_map, cv::Point(output.world_map.cols / 2, 0), cv::Point(output.world_map.cols / 2, output.world_map.rows), cv::Scalar(0, 0, 255));
    
            Odo robot_world_pose;
            robot_world_pose.x = (double)output.world_map.cols / 2.0 + (double)img_rate * (robot_pose.x - output.center_on_img.x);
            robot_world_pose.y = (double)output.world_map.rows / 2.0 + (double)img_rate * (robot_pose.y - output.center_on_img.y);
            robot_world_pose.th = 0.0;
    
            for (; world_drawer != Node.end(); world_drawer++)
            {
                int edge_out_size = (int)world_drawer->second.img_edge_out.size();
                int edge_in_size = (int)world_drawer->second.img_edge_in.size();
                if (edge_out_size == 0 && edge_in_size == 0)
                    continue;
    
                int base_idx = world_drawer->second.node_idx;
                Odo base_pose_odo;
                base_pose_odo.x = robot_world_pose.x - img_rate*output.path_on_img.at<float>(1, base_idx);
                base_pose_odo.y = robot_world_pose.y - img_rate*output.path_on_img.at<float>(0, base_idx);
                base_pose_odo.th = output.path_on_img.at<float>(2, base_idx);
    
                float xgap2center = output.center_on_img.x - output.path_on_img.at<float>(0, base_idx);
                float ygap2center = output.center_on_img.y - output.path_on_img.at<float>(1, base_idx);
                float dist2center = sqrt(xgap2center*xgap2center + ygap2center*ygap2center);
                float angle2center = 180.0f * ygap2center / abs(ygap2center) * acos(xgap2center / dist2center) / CV_PI;
                double angle_from_node = (double)angle2center - (double)output.path_on_img.at<float>(2, base_idx);
                get180Th(&angle_from_node);
                output.angle2center.at<float>(0, base_idx) = (float)angle_from_node;
    
                if (base_idx == last_localized_idx)
                    drawRobot(base_pose_odo, &output.world_map, cv::Scalar(200, 255, 200), img_rate * 20);
                else
                    drawRobot(base_pose_odo, &output.world_map, cv::Scalar(255, 200, 200), img_rate * 20);
    
    
                /*double x_dist = base_pose_odo.x - (double)ui.worldMap_mouse[0];
                double y_dist = base_pose_odo.y - (double)ui.worldMap_mouse[1];
                double dist2mouse = sqrt(x_dist*x_dist + y_dist*y_dist);
                if (dist2mouse < closest_node_dist)
                {
                    closest_node_dist = dist2mouse;
                    closest_node_idx = base_idx;
                }
    
                if (dist2mouse < 10.0 && ui.mouse.Mouse[0].change_event == 1)
                    output.mouse_pointing_idx = base_idx;
                output.mouse_chlick_flag = ui.mouse.Mouse[0].change_event;
    			*/
            }
            drawRobot(robot_world_pose, &output.world_map, cv::Scalar(255, 0, 0));
            //cv::imshow("World_Map", output.world_map);
            //mouse.setWindow("World_Map", 0);
    
            //ui.getWorldMap(output.world_map);
    		cv::imshow("world map", output.world_map);
        }
        else
        {
            cv::destroyWindow("World_Map");
        }
    
    
    
        delete[] distance;
        return output;
    }
    void MapBuilder::setOdo(double *euler, double *dist)
    {
        this->euler = euler;
        this->dist = dist;
        now_robot_odo.x = this->dist[0];
        now_robot_odo.y = this->dist[1];
        now_robot_odo.th = this->euler[2];
    }
    

  • Qt Champions 2016

    hi and welcome
    We need to see some code :)

    Is that a lib or DLL you link against?

    basically it says
    the prototype for the function , never was matched with the implementation.

    so
    where is MapBuilder::MapBuilder(void)
    implemented?



  • @mrjj Thank you for reading.
    As your request, added the code.
    MapBuilder class is a header and cpp file, not lib or dll.


  • Qt Champions 2016

    @BREEZE_KO
    but is the opencv not a DLL?

    you have a cpp file that implements
    void __cdecl MapBuilder::setOdo(double *,double *)

    ?

    else it seems that the *.cpp is not compiled with the project.

    update
    seems you have the bodies
    Output_MapBuilder MapBuilder::drawMap(void)

    so make 100% sure files are included into the build.
    U say it builds in VS2013
    so when do u get these errors?



  • @mrjj Yes opencv is a DLL and I have MapBuilder class in cpp file.

    and I understand whats wrong.
    but how to update the cpp file.
    *.pro ?
    *.pro already include all header and cpp files.
    (QNaviDemo.pro) code
    QT += core gui serialport

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = QNaviDemo
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    commdialog.cpp
    imu.cpp
    mapbuilder.cpp \

    HEADERS += mainwindow.h
    commdialog.h
    imu.h
    mapbuilder.h \

    FORMS += mainwindow.ui
    commdialog.ui

    INCLUDEPATH += C:/library/opencv3.1/build/include

    #vc14 x64
    #LIBS += C:/library/opencv3.1/build/x64/vc14/lib/opencv_world310.lib
    #vc12 x64
    LIBS += C:/library/opencv3.1/build/x64/vc12/lib/opencv_world310.lib

    I get these error in Qt-Creator, not VS2013.


  • Qt Champions 2016

    @BREEZE_KO said:

    pencv_world310.lib

    is this compiled with mingw?
    Normally a lib that works with VS compiler do not work with
    mingw compiler.
    Need to be recompiled.

    But the functions it complains about seems to be your own functions?

    the pro file looks fine if all cpp and .h are in same folder
    but i doubt
    /build/x64/vc12/lib/opencv_world310.lib
    works with mingw. Really looks like a VS dll/lib.

    to edit pro file, simple right click the project ree. u can add existing files. etc.
    or of course just edit it :)



  • Oh I used to MSVC not mingw compiler.


  • Qt Champions 2016

    @BREEZE_KO
    well if you have VS installed, why not just use it?



  • anyway I found the answer. clean - run qmake.


  • Qt Champions 2016

    @BREEZE_KO
    oh. That i assumed was tried :)
    Super.
    Sometimes solution IS super easy :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.