MinGW-w64 ver. 10.3.0 from MSYS2
Windows 10
Consider the following code within an executable's translation unit:
class __declspec(dllexport) Foo { public: int foo() { return 42; } // uncomment to export /*__declspec(dllexport)*/ static void bar(){} }; // uncomment to export //int Foo::foo() //{ // return 42; //}
When compiled with MSVC a static library with symbols is generated and can be used for linkage when building plugins.
But MinGW64 does not export any symbols, unless function implementations are outside the class body or are explicitly marked as __declspec(dllexport)
.
If the unit is build as a .dll
symbols are exported as expected like with MSVC.
This is actually an issue in binutils. For some reason, it's hrd coded to look for .dll as the target to follow DLL export rules. And fixing it is more than just building with a target of DLL and renaming the file, because the relocation table gets incorrectly built. I have a non odeal workaround somewhere, I will see if I can find later today when I have time.
Did you find it?