简体   繁体   中英

How to run an example in c++ library after CMake build

I am new to C++ programming. I need to study the working of the library g20 . I was able to successfully build the library using

cmake

command in Ubuntu. It created same folder structure as the g2o source folder structure in the build folder and a make file in each subfolder.

But after cmake how can I execute a sample program utilising the library? Can anyone please explain the steps in simple terms.

Or how can I use the library without using cmake?

I have been searching on it for quite a long time now but could not figure out how to do it.The library has provided with some examples in the folder g2o/examples/ . I could not execute even them. How can I execute them? Please help.

cmake is a building tool, which is only responsible to find the correct compiler to build the library, install it, and run the testing procedure (if set up by the authors).

Run make install to install the library, which defaults to the prefix of /usr/local (which means libraries will be installed in /usr/local/lib and executables will be installed to /usr/local/bin by default). You can edit CMakeCache.txt to change the installation directory by changing the line CMAKE_INSTALL_PREFIX:PATH=/usr/local . After installation, cmake has done its job.

I see some demos in ${g2o_source_root}/bin directory. simply execute them by typing ./bin/sba_demo or cd bin first then ./sba_demo .

You can use the library in your code like other regular libraries. Write your code in a file named yourcode.c , and compile it with gcc -llibraryname yourcode.c .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM