Skip to content

[compile error] FLANN not supported any more on Windows #6302

Open
@CSBVision

Description

@CSBVision

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions