ingkanit
ingkanit

Reputation: 13

Compiling MRPT tutorial on Ubuntu

I am following the tutorial on using the MRPT libraries for C++ on Ubuntu, but I'm not getting very far. I successfully downloaded the Ubuntu binaries according to http://www.mrpt.org/MRPT_in_GNU/Linux_repositories

Now I'm following the tutorial on writing the first C++ program with MRPT from this link

I downloaded and unpacked mrpt_example1.tar.gz in a directory, but when I run with command:

 ccmake .

there is no option to generate the code. MRPT_DIR is already set to /usr/share/mrpt, the location of MRPTConfig.cmake, so it seems ccmake has found that one. I tried setting the other options like CMAKE_BUILD_TYPE, EXECUTABLE_OUTPUT_PATH or LIBRARY_OUTPUT_PATH, but that didn't help.

How do I tell ccmake to actually compile?

Upvotes: 1

Views: 502

Answers (1)

Binary Birch Tree
Binary Birch Tree

Reputation: 15728

Instead of using ccmake, you could use cmake directly, like so:

cmake .

This will generate a Makefile in the current directory.

$ ls -1
CMakeCache.txt
CMakeFiles
cmake_install.cmake
CMakeLists.txt
Makefile
README.txt
test.cpp

You can then run make to compile the example program:

$ make
Scanning dependencies of target mrpt_example1
[ 50%] Building CXX object CMakeFiles/mrpt_example1.dir/test.o
[100%] Linking CXX executable mrpt_example1
[100%] Built target mrpt_example1

Then run the example program:

$ ./mrpt_example1
L: (0,4,2)
R: (2.000,1.000,45.00deg)
C: (x,y,z,yaw,pitch,roll)=(0.5000,0.5000,1.5000,-90.00deg,0.00deg,-90.00deg)
R+C:(x,y,z,yaw,pitch,roll)=(2.0000,1.7071,1.5000,-45.00deg,-0.00deg,-90.00deg)
Computation in: 0.0857 us
L': (-3.03553,-0.5,0.207107)
R(+)C(+)L' = (-5.82867e-16,4,2)
Should be equal to L = (0,4,2)
|(R(+)C)-L|= 3.0834
|L-(R(+)C)|= 3.0834

Note that you should start by extracting a clean copy of the contents of mrpt_example1.tar.gz, and perform these steps in the clean copy.


Alternatively, you could use the version of the example project that provides a Makefile out-of-the-box, and does not require CMake:

https://github.com/MRPT/mrpt/tree/master/doc/mrpt_example1-with-Makefile

This is covered in the following tutorial:

http://www.mrpt.org/tutorials/programming/first-steps/compiling_custom_applications_in_linux_with_a_makefile_and_pkg-config/


Otherwise, if you must use ccmake:

First, extract a clean copy of the contents of mrpt_example1.tar.gz.

Enter the extracted mrpt_example1 directory and run:

ccmake .

This will present an interactive dialog with the following options:

Press [enter] to edit option
Press [c] to configure
Press [h] for help           Press [q] to quit without generating
Press [t] to toggle advanced mode (Currently Off)

Press c to configure. The top of the screen will now show:

CMAKE_BACKWARDS_COMPATIBILITY   *2.4
CMAKE_BUILD_TYPE                *
CMAKE_INSTALL_PREFIX            */usr/local
EXECUTABLE_OUTPUT_PATH          *
LIBRARY_OUTPUT_PATH             *
MRPT_DIR                        */usr/share/mrpt

Press c to configure again. The following options will now be available:

Press [enter] to edit option
Press [c] to configure       Press [g] to generate and exit
Press [h] for help           Press [q] to quit without generating
Press [t] to toggle advanced mode (Currently Off)

Press g to generate the output files (which includes the Makefile) and exit.

Notice that a Makefile has been generated:

$ ls -1
CMakeCache.txt
CMakeFiles
cmake_install.cmake
CMakeLists.txt
Makefile
README.txt
test.cpp

You can run make to compile the example program, then run the example program once it has been compiled, as described above.

Upvotes: 2

Related Questions