Using PCL with Eclipse - c++

I wish to use PCL with Eclipse on Ubuntu. Now, that's what I did this far:
a) Installed PCL with apt-get:
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
b) Created new project in eclipse
~/workspace/hello_pcl/
c) In above folder created src/pcd_write.cpp from this source.
d) Created following CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(hello_pcl)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
e) Set include path /usr/include/pcl-1.7/ in project setting
My question is: What I should do now to build projects with Eclipse? Should I make the project with cmake:
cd ~/workspace/hello_pcl/build
cmake ../src
make
Or should I do something else? I'm fairly new to cmake.
I suppose I should add libraries to project setting, but didn't find on pcl page, what are names of these libraries...
EDIT:
OK, thanks to the comment I was able to create and run the hello_pcl application (I used solution from How to configure eclipse CDT for CMake), but now I have further issue. Application works, but the Eclipse code editor still underlines all PCL-dependent commands and signs them as Field [...] could not be resolved as well as includes Unresolved inclusion [...]. Strangely, #include <iostream> makrs also as unresolved. Should I include somehow PCL libraries?

I have managed to solve my problem, this is what I have done:
Basically, point from a) to d) are correct (though I have created the project not in eclipse workspace folder, but in ~/). Now is the trick: It seems, that when following typical workflow for using CMake with Eclipse CDT, indexer behaves incorrectly. Even after adding specific include path to Path and Symbols in project properties.
What is essential here, is that after creating CMakeLists.txt (maybe for start is better to set target_link_libraries for all libraries - ${PCL_LIBRARIES}), one has to build the project with (in my case):
cd ~/hello_pcl/build
cmake -G "Eclipse CDT4 - Unix Makefiles" ../src
Of course, if You want to have Debug build, You have to specify proper option.
Next step is to add project to eclipse workspace but not as a Makefile project, but as general project, that is:
File -> Import -> General -> Existing projects into workspace.
Place path to the build folder in Select root directory (~/hello_pcl/build in my case) and click Finish.
This is the moment, when indexer parses all includes. And it takes a lot of time. But after that, everything seems to work fine.

Related

Unable to setup vcpkg CMAKE_TOOLCHAIN_FILE with KDevelop

I have installed vcpkg according to the instructions provided here. I installed the libraries I wanted (in this case fmt and boost), then created a simple new project in KDevelop which runs just fine. Then to add my libraries to the project I added -DCMAKE_TOOLCHAIN_FILE=/VCPKG_LOCATION/vcpkg/scripts/buildsystems/vcpkg.cmake in the "Configure CMake settings", where there is an "Extra arguments field", of KDevelop (Right click on Project folder and then "Open Configuration...").
Then I simply added the following to my CMakeLists.txt:
find_package(fmt REQUIRED)
and I get the following error:
By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"fmt", but CMake did not find one.
Could not find a package configuration file provided by "fmt" with
any of the following names:
fmtConfig.cmake
fmt-config.cmake
Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set
"fmt_DIR" to a directory containing one of the above files. If
"fmt" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
It seems that KDevelop is not recognizing the toolchain file (even though I can clearly see in the build log that that CMake is being called with the "-DCMAKE_TOOLCHAIN_FILE" as required). I have tried to setup the project similarly in Qt Creator which does seem to work perfectly fine.
You can install fmt package. With gcc/g++ installed,
git clone https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install

Eclipse doesn't see include files when checking syntax but does when building or running the application

I started with building my project with CMake by using the cmake <folder> -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug command (I'm using Ubuntu 14.04). Say the results were written to /home/student/tempFolder/HelloFrameworkApp folder.
The thing is that I have header files needed for he application in /home/student/git/fagot/sw/branches/head/framework/include folder. This is also described in CMakeLists so after I import my project from /home/student/tempFolder/HelloFrameworkApp to Eclipse as existing code as makefile project, it can successfully be built and runs just as expected.
But in the code edit area there are tons of red underlining which makes it clear that Eclipse can't see the include folder I mentioned before. I tried going to Properties -> C/C++ General -> Paths and symbols and adding that include folder to all configurations and languages but it didn't help.
Any suggestions?
CMake creates an Eclipse project for you. Therefore you need to use: Import->General->Existing Project into Workspace.

How to change where CMakeLists.txt looks for Boost Libraries Ubuntu

I was using Boost 1.54.0 and it was located in "/usr/include". We blew that away and installed Boost 1.57.0. It got installed in "/usr/local/include".
Now, my CLion project, which uses CMake cannot find the Boost library. Here is my CMakeLists.txt file:
And here are my errors:
I have no idea how to make CMake look in the correct place for Boost.
According to the FindBoost documentation (http://www.cmake.org/cmake/help/v3.1/module/FindBoost.html), you can set a CMake variable BOOST_ROOT to give CMake a hint about where to look.
In your CMakeLists.txt file, you can add the following before the find_package(Boost...) line:
set(BOOST_ROOT /usr/local)
Update:
I agree with the comments that putting machine specific configuration parameters directly in CMakeLists.txt is not best practice.
As an alternative to directly setting this variable, you can pass options like this to the cmake process in CLion by doing the following:
Navigate to File -> Settings... -> Build, Execution, and Deployment -> CMake. Under Generation, add -DBOOST_ROOT=/usr/local to CMake options.

Eclipse indexer not working

I'm trying to set up PCL with eclipse. I have never did any CMake stuff, so I don't really know what is going on.
I have installed PCL with apt-get. Next, I made folder ~/hello_pcl/src, where I saved pcd_write.cpp file and following CMakeLists.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(hello_pcl)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcd_write_exe pcd_write.cpp)
target_link_libraries (pcd_write_exe ${PCL_LIBRARIES})
Next, I've done:
cd ~/hello_pcl
mkdir build
cd build
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ../src
As for the last, I have imported created project into eclipse with File -> Import -> C/C++ -> Existing code as Makefile project.
My problem is: after that, the application runs correctly, but Eclipse code editor marks all includes as Unresolved inclusion and almost every function as Unresolved symbol. Strangely, it does it also with #include <iostream>. I figured out, that it's a problem with indexer. Therefore, I have add /usr/include/c++/4.8 and /usr/include/pcl-1.7 in Project properties -> C/C++ general -> Paths and symbols in Includes tab and GCC C++ language.
It seems to have resolved some of the issues, but there are still functions, that are marked red (see screenshot).
Anyone knows how to solve this problem?
I solved my problem.
It seems, that in this case, typicas workflow for using Eclipse CDT with CMake makes indexer work incorectly.
What I have done is, after invoking cmake command, imported project not as Makefile project, but with Import -> General -> Existing projects into workspace.
After importing project in this way, indexer takes really lot of time (and I suppose it can crush Eclipse, if project is big enough) to parse all includes. But after that everything works fine.

Trouble building the Open Asset Import Library (Assimp)

I have just downloaded the Open Asset Import Library (Assimp) which is an API used to import 3D file formats such as .3DS and .Obj into source code. Doing so allows for much easier rendering of meshes using openGL.
The problem is, I can't get the Library to build. It comes with very vague and cryptic directions on how to build it and connect to a compiler such as XCode (which I am using). It says I should use a program called CMake to build the library. I have downloaded CMake and tried to use it but it has not yet worked for me.
Has anyone here successfully built and installed Assimp using CMake or some other tool?
I totally agree that the documentation for Mac is a bit lacking, but I have managed (after several attempts) to build and install the library.
A few things before starting: make sure you have installed XCode Command Line Tools (that installs the GNU compiler).
These are the steps I followed:
Download the latest release of Assimp and extract it (I got the file
from here, the one with source only:
http://sourceforge.net/projects/assimp/files/assimp-3.0/)
If you don't have it, install CMake (http://www.cmake.org/cmake/resources/software.html; I'm currently using an older version, but the latest one should work fine as well)
Create a build directory (should be outside the source directory)
Open CMake and point it to the folder you created at step 1 (where it says "Where is the source code"); the other folder ("Where to build the binaries") should point to the folder created at step 3
Click "Configure" on the bottom; it will ask you which environment you'd like to use. I picked "Eclipse CDT 4 - Unix Makefiles"
You should get a list of options; the two I selected were "BUILD_STATIC_LIB" and "ENABLE_BOOST_WORKAROUND"
Click "Generate"
Now you should move to the terminal and go to the folder created at step 3
Type "make" and launch it; you should see the build progressing without issues
When the build is finished, type "sudo make install"; it will ask for your password and install the library
After the last step you should be able to include the library in your code:
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
Make sure you also include the library for linking; when linking you should add -lassimp to the list
Let me know if you have any issues with the steps above!
I had a slightly different approach that worked for me building assimp on Mac. Here are the steps that I took if it helps anybody.
Step 1 - Install Libraries with Homebrew
brew install glm glew assimp
Step 2 - Update my CMake with the Following
FIND_PACKAGE(ASSIMP REQUIRED)
LINK_DIRECTORIES(/usr/local/lib)
add_executable(
myExecutable
...
)
TARGET_LINK_LIBRARIES( myExecutable PRIVATE ${ASSIMP_LIBRARIES} )