ubuntu14 + cmake3.2 + eigen3

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_33810188/article/details/82598561

A recent study slam, ubuntu14.04 installed on the notebook, also updated to version 3.2 cmake, in addition to installing a common matrix arithmetic library eigen

Special record it, process C ++ programming in linux system (start learning a new system, there are indeed many are not familiar with)

EigenMatrix.cpp established under (./test) a folder directory

Inside input

----------------

#include <iostream>

#include <Eigen/Core>

#include <Eigen/Dense>

int main(int argc,char **argv)

{

Some conventional eigen // input operation command, e.g.

Eigen::Matrix<float,2,2> matrix_22;

matrix_22<<1.0,2.2,3.0,4.0;

std::cout<<matrix_22<<std::endl;

return 0;

}

-----------------

After building cpp files, you can make CMakeLists.txt file (Note that the name can not be changed!)

Inside input

-----------------

cmake_minimum_required (VERSION 3.2) // camke minimum version

project (eigenTest) // project name, free to take

include_directories ( "/ usr / include / eigen3") // comprising eigen headers (note path)

add_executable (eigenMatrix eigenMatrix.cpp) / add cpp files need to be addressed (note format)

-----------------

The next step may be to create a subdirectory (will analyze and compile files on manageable together)

sudo mkdir build // Create a subdirectory

cd build // make the terminal into the subdirectory

-----------------

Start analyzing .cpp file

Special attention sudo cmake .. // '..' (represented by a directory on two points, one point represents the current directory!)

After no mistake, it can be compiled (there is a problem, need to see an error message, or log file)

sudo make // do not need to point number

After no errors, the compiled program can be executed, the test results can be displayed immediately

./eigenMatrix // note format and file name!

-----------------

General error-prone place is

Of course, the premise is to configure the environment to be correct (cmake + eigen)

1. Write the code error

2.eigen header file directory is wrong (installed by default, generally not a problem)

3.CMakeLists.txt file name is wrong, as well as inside the code is malformed

4.cmake programming syntax error

The document processing system of linux command error, improper use of the file path and

Guess you like

Origin blog.csdn.net/qq_33810188/article/details/82598561