0
votes

I faced below error when I tried to install the flann library from the source on the ubuntu machine.

/flann-master/src [72] mkdir build

/flann-master/src [73] cd build

/flann-master/src/build [74] cmake ..

CMake Warning (dev) at cpp/CMakeLists.txt:3 (add_definitions): Policy CMP0005 is not set: Preprocessor definition values are now escaped automatically. Run "cmake --help-policy CMP0005" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at cpp/CMakeLists.txt:114 (install): install TARGETS given no LIBRARY DESTINATION for shared library target "flann_cpp".

CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

/flann-master/src/build [75]

The solution to this was mentioned in another question. I should be in the root directory (containing bin, src, examples etc) and it solved. And there is another missing part in the documentation that I should run

make install

As I am sudoer on the remote machine, I need to install it on my home directory. So, I created a new directory outside of the flann (flanninstall) and I tried below command.

cmake -DCMAKE_INSTALL_PREFIX=/home/eson/matlab/flanninstall/ ..

I hope it helps me to generate the files in my home directory and I can copy or link them to matlab. However, I copy the files from this address to current directory that I am working on my script in matlab. I still get below error.

-> g++-4.4 -c -I/usr/local/MATLAB/2012a/extern/include -I/usr/local/MATLAB/2012a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -O -DNDEBUG "nearest_neighbors.cpp"

nearest_neighbors.cpp:35: fatal error: flann/flann.h: No such file or directory compilation terminated.

mex: compile of ' "nearest_neighbors.cpp"' failed.

Error using mex (line 206) Unable to complete successfully.

Earlier @rayryeng helped me on the MEX setup but when I try to run below command I faced earlier problem.

mex -v -O nearest_neighbors.cpp

I appreciate your advice.

1
You have to execute the root CMakeLists.txt. You're building /flann-master/src/build [74] cmake .., i.e., src/CMakeLists.txt so it's wrong. You must create your build folder into root one and then run it-> /flann-master/build$ cmake ..fenix688
Thanks @fenix688, I found that and I mentioned it in the middle of my question. That was the first problem that I had.Ehsan Sadr

1 Answers

0
votes

I just found out that I need to set the LD_LIBRARY_PATH in linux for my user. The command will be :

export LD_LIBRARY_PATH="/home/eson/alg/matlab/flanninstall/lib:$LD_LIBRARY_PATH"

This is different path that normal path that you should add if you have root access or sudo access on your machine. That would be something similar to below line:

export LD_LIBRARY_PATH="/Your_build/build/lib:$LD_LIBRARY_PATH"

The above path should not be completely right, because it could be something that start with /usr/local/ or /usr/include/ . If I understand the exact path for general case or others have the complete answer, I will update it.