pcl icon indicating copy to clipboard operation
pcl copied to clipboard

Can't link pcl components while compiling with RelWithDebInfo

Open Faroito opened this issue 2 years ago • 5 comments

Describe the bug

When compiling PCL with CMAKE_BUILD_TYPE to RelWithDebInfo, PCLConfig.cmake doesn't find pcl components.

Expected behavior

I would expect that the find_library in PCLConfig would also search for ${pcl_component}rd

Current Behavior

The find_library only search for Debug and Release suffixes.

To Reproduce

Build PCL with RelWithDebInfo and then link it to your project.

Your Environment:

  • OS: Windows 11
  • Compiler: VS 2019
  • PCL Version 1.11 but I don't think this is resolved on master

Edit: I think the same would happen with MinSizeRel build Edit2: This bug is only on Windows build

Faroito avatar Feb 07 '23 15:02 Faroito

@Faroito What is the exact error message you get? Can you perhaps post CMake's log?

mvieth avatar Feb 07 '23 20:02 mvieth

I get a lot of undefined references such as error LNK2019: unresolved external symbol "void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const *,...)" (?print@console@pcl@@YAXW4VERBOSITY_LEVEL@12@PEBDZZ) referenced in function "protected: virtual void __cdecl pcl::IterativeClosestPoint<struct pcl::PointXYZ,struct when compiling my project against PCL

None of the pcl libraries are in PCL_LIBRARIES cmake variable.

To fix it, I added

set(PCL_RELWITHDEBINFO_SUFFIX "@CMAKE_RELWITHDEBINFO_POSTFIX@")

and

find_library(PCL_${COMPONENT}_LIBRARY ${pcl_component}${PCL_RELWITHDEBINFO_SUFFIX}
    HINTS ${PCL_LIBRARY_DIRS}
    DOC "path to ${pcl_component} library RelWithDebInfo"
    NO_DEFAULT_PATH)

in PCLConfig.cmake.in

Faroito avatar Feb 07 '23 22:02 Faroito

I can make a pull request if needed

Faroito avatar Feb 08 '23 09:02 Faroito

Adding code in PCLConfig.cmake.in for RelWithDebInfo and MinSizeRel sounds logical to me, but I don't really have experience with Windows, so tagging @larshg and @UnaNancyOwen Anyway I think what you suggested isn't sufficient yet: cmake would have to check which of the four library types are available and set the target properties of ${pcl_component} accordingly. In your suggestion, RelWithDebInfo would simply overwrite Release, correct? Possibly related: https://github.com/PointCloudLibrary/pcl/pull/3055

mvieth avatar Feb 09 '23 20:02 mvieth

Anyway I think what you suggested isn't sufficient yet: cmake would have to check which of the four library types are available and set the target properties of ${pcl_component} accordingly. In your suggestion, RelWithDebInfo would simply overwrite Release, correct?

That is right, I just did a quick fix for my use case.

Faroito avatar Feb 09 '23 21:02 Faroito

Fixed by https://github.com/PointCloudLibrary/pcl/pull/6089

mvieth avatar Jul 19 '24 13:07 mvieth