I'm porting a rather large project/library from Linux to Windows and was looking for an automatic symbol export solution, and found the WINDOWS_EXPORT_ALL_SYMBOLS to be excellent. It works almost nicely, however there is a problem with the .def file it creates.
Upon linking I get errors like this:
exports.def : warning LNK4022: cannot find unique match for symbol '_CT??_R0?AU?$error_info_injector'
exports.def : warning LNK4002: _CT??_R0?AU?$error_info_injector@Ubad_day_of_month@gregorian@boost@@@exception_detail@boost@@@864 defined in ...
exports.def : warning LNK4002: _CT??_R0?AU?$error_info_injector@Ubad_month@gregorian@boost@@@exception_detail@boost@@@864 defined in ...
exports.def : error LNK2001: unresolved external symbol _CT??_R0?AU?$error_info_injector
Apparently, the .def file has lines like this which cause the problem:
If I manually delete the lines referenced in the above errors from the generated .def file, the DLL builds fine.
The project uses a lot of third party libraries, boost is one of them. The symbols that cause the problem are probably not even need to be exported.
So my question is, how can I solve this? My first idea was to create a sort of "blacklist" and write a script that "heals" the .def file by removing the problematic lines. However it is not possible to do, as the WINDOWS_EXPORT_ALL_SYMBOLS step is added internally by CMake as a final PRE_LINK step, and I found no way add a command between the .def file generation and the actual linking.
I thought about adding a custom command which would emulate the behaviour of WINDOWS_EXPORT_ALL_SYMBOLS, however I cannot easily get the object file list in a convenient file as WINDOWS_EXPORT_ALL_SYMBOLS does.
So I'm stuck at this point, any help would me much appreciated.
I probably found a bug as well in the process. If I enable WINDOWS_EXPORT_ALL_SYMBOLS but I also add a custom PRE_LINK step with add_custom_command() like this: