MinGW GCC generating DLL for dynamic link Libraries Summary (supplemental)

Source: Internet
Author: User
I have written a short essay about the problems of MinGW GCC generating DLL for dynamic link libraries. The writing was not comprehensive at the time. Recently, I have encountered writing new questions. Here's a note to make a supplement.

Normally, if a function in a DLL takes _stdcall, the function name in the generated DLL is decorated.
For example, there are the following functions:

Dll.c
int _stdcall Add (int a, int b)
{
return a + B;
}

The function name in the final DLL file is [email protected]

But sometimes we want the function name not to add this adornment, just like the Windows API function. If we use the VS compiler, we need to write a def file. If you export a lot of functions, this is cumbersome.
The use of MinGW gcc is much simpler. The following statements can be implemented:

GCC dll.c-shared-o dll2.dll-wl,--kill-at,--output-def,dll2.def,--out-implib,dll2.a

The function name in this generated dll2.dll does not have an extra decoration.

How this DLL is used. When we compile with GCC we need to pass a parameter to the linker:

GCC-WL,--enable-stdcall-fixup main.c dll2.a-o test.exe

MinGW GCC generating DLL for dynamic link Libraries Summary (supplemental)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.