WINDOWS_EXPORT_ALL_SYMBOLS causes invalid export symbol names on C++/CLI projects
Environment:
- CMake Version: 3.16.0
- Generator: Visual Studio 16 2019
- The CXX compiler identification is MSVC 19.25.28612.0
How to reproduce:
-
Create a shared library that contains a c++ file using C++/CLI
-
Set the following properties:
set_target_properties(cliLib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON COMMON_LANGUAGE_RUNTIME "")
-
Compile and link the library
Expected result:
- The library compiles and links fine
Actual result:
- Linking fails with:
build/cliLib.dir/Debug/exports.def : fatal error LNK1242: '?@?
context_node@PEBDPE
AAVString@System@@@interop@msclr@@$FME
AAMX_N@Z' is an invalid export symbol name
I have attached a small project that reproduces the issue.
It looks like that the linker cannot handle C++/CLI (managed) symbols. These symbols can be identified by "$$F" according to https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling
When I remove all symbols containing "$$F" and the symbols (__t2m, __m2mep and __mep) from the exports.def file, everything works.