Fix: Avoid symbol export when building statically with MSVC #1020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🛠️ Fix: Avoid unnecessary symbol export with static MSVC builds
Summary
This patch ensures that
__declspec(dllexport)
is not applied when Aravis is built statically with MSVC. It updates the logic inmeson.build
to conditionally apply theARV_API
macro only for shared builds, improving compatibility and cleanliness of static builds on Windows.🔍 Problem
When building Aravis statically with MSVC (e.g., via vcpkg with x64-windows-static triplet), the current build system still applies
__declspec(dllexport)
globally. This leads to:.lib
and.exp
files next to user executables.This behavior is not aligned with standard MSVC conventions, where symbol export macros are only needed in shared (DLL) builds.
✅ Solution
This patch modifies the logic in
meson.build
:Now, when
default_library
is'static'
, no__declspec(dllexport)
is added — restoring correct static build behavior.Also, this patch explicitly adds:
to the
project()
declaration inmeson.build
. This ensures that unless otherwise specified, builds will default to shared libraries, preserving existing workflows and expectations.Users who want static builds can still explicitly override this with:
💡 Justification
This change:
.exp
/.lib
files when building user executables.ARV_API
macro or ABI.🧠 Historical Context
This aligns with an earlier discussion in PR #550 (2021), where initial MSVC support was proposed. Back then:
ARV_API
was added to manage symbol visibility.ARV_API
should be conditional and not clutter headers unnecessarily.🧪 Testing
Confirmed working with:
/MTd
).exp
/.lib
artifacts appear at app link time.🔗 Related