Skip to content

Conversation

@revmischa
Copy link
Member

PCM is an internal class with the C API (projectm_pcm_*) providing the public interface. Exporting these methods caused symbols to leak into the shared library even when ENABLE_CXX_INTERFACE was off.

Verified with nm -D that the C++ PCM class symbols are no longer exported while the C API functions remain available.

Fixes #937

@revmischa revmischa requested a review from kblaschke January 10, 2026 19:59
@kblaschke
Copy link
Member

I was already working on that issue, see my early WIP branch: https://github.com/kblaschke/projectm/commits/fix-pcm-exports/

There are actually exports missing instead of being too many. These exports are required for the ENABLE_CXX_INTERFACE option, otherwise libprojectM (static or shared) won't link to apps using the C++ interface due to unresolved symbols. The actual fix requires a new export header for the C++ interface, so these export macros can be toggled separately. So there's the existing PROJECTM_EXPORT macro for the default C API functions, and I'll add a new one, PROJECTM_CXX_EXPORT, for the C++ interface.

Added separate export header, export macros for all required classes and functions and installing the headers in the correct directory structure.
@kblaschke kblaschke force-pushed the fix/pcm-export-visibility branch from c6a8823 to fb1505a Compare January 20, 2026 14:26
@kblaschke
Copy link
Member

Properly fixed the whole ordeal, which was way more complex than I thought due to how Windows declares exports/imports and some other things which were wrong or missing in the CMake files. Here's what I've done:

  • Always build the project with "hidden" default visibility, e.g. no exported symbols except those marked as such.
  • Added another export header for the C++ interface, so the exports can be enabled separately.
  • Added the new C++ export macro 'PROJECTM_CXX_EXPORT` to all required classes and static functions (Logging).
  • Fixed how those export macros are set or used within the code base.
  • Added a small test executable that can be built to verify the required classes are properly exported and thus can be linked, even with a shared projectM library.
  • Added the C++ API checks as an additional build step on desktop platforms. Android and Emscripten are basically Linux builds, so I don't test it in those.

Depending on how projectm-eval has been built, its symbols might end up being visible in nm's output. Besides that, only the C API and, if the C++ interface is enabled, the specifically exported classes and members are now visible externally.

@kblaschke kblaschke requested review from blaquewithaq and mbaetgen-wup and removed request for kblaschke January 20, 2026 14:34
@kblaschke kblaschke merged commit fb1505a into master Jan 20, 2026
37 checks passed
@kblaschke kblaschke deleted the fix/pcm-export-visibility branch January 20, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEV BUG] Some members of the PCM class are exported in the shared library

3 participants