'MFC header afxwin.h in a dynamic library generating link error

I'm trying to use MFC headers, such as #include <afxwin.h>, in a dynamic library project.

The structure looks like this:

Project Solution
|
|- DynamicLib
     |
     |- main.cc

main.cc contains the header.

I have the /MD compiler flag on, but the solution won't compile.

In the generated exports.def file, there's a __ DATA field that's causing the issue.

When I remove it manually, the solution compiles.

Here's the (useless) linker error:

1>exports.def : warning LNK4022: cannot find unique match for symbol '__'
1>exports.def : warning LNK4002: __@@_PchSym_@00@UwvevolknvmgUlhhprmUxnzpvUlhhprmRyfrowUlhhprmOwriUwvyftUhgwzucOlyq@4B2008FD98C1DD4 defined in MyDir.dir\Debug\stdafx.obj
1>exports.def : warning LNK4002: __@@_PchSym_@00@UzABUPdlipUDUhUrmgvinvwrzgvUexgllohUzgohOmzgrevkilqPBACIAJCBDBUlyqiUznwGEUhgwzucOlyq@4B2008FD98C1DD4 defined in d:\a01\_work\3\s\Intermediate\vctools\atls.nativeproj_1028092131\objr\amd64\stdafx.obj
1>exports.def : error LNK2001: unresolved external symbol __

Is there anything else that should be added to the compiler flags for this to be corrected?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source