PointCloudLibrary / PointCloudLibrary/pcl

[compile error] FLANN not supported any more on Windows

Open
#6,302 16 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind: compile error module: search
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Describe the error

Hello,

We are into some trouble compiling PCL on Windows. In particular, compiling with support of

  • Eigen 3.4.0
  • Boost 1.88.0
  • VTK 9.5.0
  • QHull 8.0.2

alone works fine. However, including FLANN seems to be broken.

To Reproduce

First, FLANN has to be compiled, but seems to be unmaintained. The latest release 1.9.2 does not compile on Windows (due to a pkg config dependency), whereas 1.9.1 does compile, but needs a few adjustments to work with the latest Visual Studio/compiler updates:

  • #include <functional> is missing in flann/util/heap.h, which can be fixed by adding /FI functional to the CMAKE_CXX_FLAGS
  • Visual Studio tries to compile the files lz4.c lz4hc.c as C files, however they need to be compiled as C++, which can only be fixed in the generated vsxproj file, as the /TP flag is not forwarded by CMake.

With these two fixes, FLANN 1.9.1 compiles. Clearly, so far this is independent of PCL, still compiling PCL has the same issues.

Thereafter, including FLANN in the PCL build by defining FLANN_INCLUDE_DIR and FLANN_LIBRARY_STATIC accordingly while running CMake works fine, however compiling PCL thereafter will fail.

We analyzed the issues and according to our tests, the following steps are necessary to fix the issues:

  • Define CMAKE_CXX_STANDARD=14 as std::random_shuffle() is used by FLANN (e.g. flann/util/random.h), but unavailable with C++17.
  • The #include <functional> is missing such that adding /FI functional to CMAKE_CXX_FLAGS resolves this, too.
  • The definition /DEIGEN_MAX_ALIGN_BYTES=32 is required due to warning stating Potential runtime error due to aligned malloc mismatch!.
  • The two files kiss_fft.c and kiss_fftr.c need to be compiled explicitely as C++.

Surprisingly, these issues seem not to be discussed here so far. Is FLANN not supported by PCL on Windows any more? It seems rather complicated to use, and nanoflann is not a full replacement yet, as several modules are not available with nanoflann alone.

Your Environment (please complete the following information):

  • OS: Windows 11
  • Compiler: Visual Studio 2022 Version 17.14.7
  • PCL Version: Master
  • PCL Type: Compiled from source

If PCL was compiled from source or failure in compiling PCL itself:

  • GPU, Kinfu, CUDA enabled? No
  • List and Version of dependencies used: see above
  • Compilation flags used: Paths to the dependencies are set explicitly, everything else are default.

Possible Solution

Manually changing the build configuration flags as described.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows build with FLANN enabled, focusing on flann/util/random.h, flann/util/heap.h, kiss_fft.c, and kiss_fftr.c and the CMake configuration described in the report. Done means PCL compiles with FLANN on the stated Visual Studio environment without manually editing generated project files.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.