# Clang-cl and CMAKE\_WINDOWS\_EXPORT\_ALL\_SYMBOLS

**URL:** https://discourse.cmake.org/t/clang-cl-and-cmake-windows-export-all-symbols/2009
**Category:** Usage
**Created:** [October 16, 2020, 7:19am UTC](https://discourse.cmake.org/t/clang-cl-and-cmake-windows-export-all-symbols/2009 "2020-10-16T07:19:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Horyu](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/c6cbf5/32.png) [@Horyu](https://discourse.cmake.org/u/Horyu)
#### Post date: [October 16, 2020, 7:19am UTC](https://discourse.cmake.org/t/clang-cl-and-cmake-windows-export-all-symbols/2009/1 "2020-10-16T07:19:51Z")

</div>

Hi,  
I’m building cross-compiled apps for Windows under Linux.  
I use the [openssl-cmake](https://github.com/janbar/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:

> \_AES\_cbc\_encrypt

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 ?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 25, 2020, 12:04am UTC](https://discourse.cmake.org/t/clang-cl-and-cmake-windows-export-all-symbols/2009/2 "2020-11-25T00:04:48Z")

</div>

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

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 25, 2020, 12:22pm UTC](https://discourse.cmake.org/t/clang-cl-and-cmake-windows-export-all-symbols/2009/3 "2020-11-25T12:22:00Z")

</div>

For reference, CMake learned to use llvm-nm for this in [CMake MR 4081](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4081).
