Skip to content

Commit 1d6a567

Browse files
imikejacksonclaude
andcommitted
fix(win): export embedded LibMTRSim symbols from the plugin DLL on MSVC
The plugin-build shim hard-coded LIBMTRSIM_EXPORT to empty. On Unix that is fine (default visibility exports the symbols), but on MSVC nothing is exported from the plugin DLL, so external consumers (MTRSimUnitTest, the Python bindings) fail to link mtrsim:: free functions (readODFComponents, readODFMetadata, tryReadFixtureVersion) with LNK2019/LNK1120. Key the macro on MTRSim_EXPORTS (dllexport when building the plugin, dllimport when consuming), matching the plugin's own export macro. macOS build + 42/42 tests unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1fb3b4e commit 1d6a567

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/MTRSim/libmtrsim_export.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
/**
2-
This file is here because we are including all the LibMTRSim sources into the
3-
simplnx plugin. In order to do that, this file with this define needs to be
4-
here.
5-
*/
2+
* The LibMTRSim sources are compiled directly into the SIMPLNX MTRSim plugin
3+
* shared library (rather than a standalone libMTRSim). This shim defines the
4+
* LibMTRSim export macro so the LibMTRSim symbols are exported from / imported
5+
* into the plugin DLL exactly like the plugin's own symbols. Without this, on
6+
* MSVC the LibMTRSim symbols (e.g. mtrsim::readODFComponents) are not exported
7+
* from the plugin DLL and external consumers -- the unit-test executable and
8+
* the Python bindings -- fail to link with LNK2019 / LNK1120. On non-Windows
9+
* the symbols use default visibility (the prior behavior).
10+
*
11+
* CMake defines `MTRSim_EXPORTS` while building the plugin target.
12+
*/
13+
#pragma once
614

7-
#define LIBMTRSIM_EXPORT
15+
#ifndef LIBMTRSIM_EXPORT
16+
#ifdef _WIN32
17+
#ifdef MTRSim_EXPORTS
18+
#define LIBMTRSIM_EXPORT __declspec(dllexport)
19+
#else
20+
#define LIBMTRSIM_EXPORT __declspec(dllimport)
21+
#endif
22+
#else
23+
#define LIBMTRSIM_EXPORT __attribute__((visibility("default")))
24+
#endif
25+
#endif

0 commit comments

Comments
 (0)