I’m building cross-compiled apps for Windows under Linux.
I use the openssl-cmake project to build openssl, it works fine to build static libraries, but when tryiing to build shared libraries, it exports the CMake value CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS, it works fine, all symbols are exported, but the exports.def file contains the exported names, not the symbols names. For example, in libcrypto’s def file:


Making the linker prepend another ‘_’:

ld-link-9: error: : undefined symbol: __AES_cbc_encrypt

If I modify by hand the def file and remove all the ‘_’, it builds the .lib and .dll files.
There is another catch tho as it seems to depend on the call convention as _async_start_func_win@4 is just fine, no need to remove or add anything.

From the cmake source code, I believe the nm command to dump symbols is the following:

llvm-nm-9 --no-weak --defined-only --format=posix crypto/CMakeFiles/crypto.dir/async/arch/async_win.c.obj
@feat.00 a 1 0
_ASYNC_is_capable T 0 0
_async_fibre_init_dispatcher T 0 0
_async_local_cleanup T 0 0
_async_start_func_win@4 T 0 0

Any thoughts on this kind of behavior ?

I suspect that we might need a post-processing step on it for this situation.

Cc: @brad.king

For reference, CMake learned to use llvm-nm for this in CMake MR 4081.