Menu

#906 MinGW-w64 does not export symbols from an executable

v1.0 (example)
open
nobody
None
5
2021-12-28
2021-06-23
No

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.

Discussion

  • Doug Semler

    Doug Semler - 2021-07-13

    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.

     
    • Sergey Kolesnik

      Sergey Kolesnik - 2021-12-28

      Did you find it?

       

Log in to post a comment.