PointCloudLibrary / PointCloudLibrary/pcl

PCL_EXPORTS seems to be implemented wrong

Open
#2,708 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind: proposal module: cmake needs: author reply skill: cmake status: stale
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

I currently still trying to compile everything with MSVC. I could fix already a lot of issues, but there is an error I couldn't fix:

LNK2001	unresolved external symbol "public: static struct QMetaObject const pcl::cloud_composer::PropertiesModel::staticMetaObject" (?staticMetaObject@PropertiesModel@cloud_composer@pcl@@2UQMetaObject@@B)	pcl_cc_tool_fpfh_estimation

In general I could fix all linker errors, except where we export a target with Q_OBJECT:

    class PCL_EXPORTS AbstractTool : public QObject
    {
      Q_OBJECT
      //...
    }

If you search the web for this issue you always find, that we need __declspec(dllimport). But PCL_EXPORTS expand always to __declspec(dllexport) or empty.

Further issue: PCL_ADD_LIBRARY always add symbol PCLAPI_EXPORTS. This seems at first look correct, but I believe this is partially wrong.

  • Case 1: Someone build PCL and use installed libraries. In this case everything is fine, because PCLAPI_EXPORTS is not defined
  • Case 2: A PCL library (LibA) is using another PCL library (LibB). In this case PCLAPI_EXPORTS should be true for all header files part of LibB but no defined for LibA during building LibB. So I believe it would be correct if define PCL_LibA_EXPORTS and PCL_LibB_EXPORTS instead of just PCL_EXPORTS.

And we use should CMake::GenerateExportHeader.

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 MSVC linker failure for Q_OBJECT classes and trace how PCL_EXPORTS and PCL_ADD_LIBRARY define export symbols. Compare the current behavior with CMake::GenerateExportHeader and verify that dependent libraries receive the correct import or export annotations without unresolved staticMetaObject symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.