Didier Stevens

Tuesday 28 August 2018

Quickpost: Compiling DLLs with MinGW on Windows

Filed under: Quickpost — Didier Stevens @ 0:00

MinGW is not only available on Kali, of course, but also on Windows. Compiling a DLL is very similar.

MinGW is installed in folder C:\msys64 on my machine.

 

To compile 64-bit executables, you need to start the 64-bit shell first: launch C:\msys64\mingw64.exe

Then you can compile the DLL:

gcc -shared -o DemoDll-x64.dll DemoDll.cpp

For 32-bit executables, it’s the 32-bit shell: launch C:\msys64\mingw32.exe

Then you can compile the DLL:

gcc -shared -o DemoDll-x86.dll DemoDll.cpp

 

It’s also possible to start the shell and compile from a BAT file:

call C:\msys64\msys2_shell.cmd -mingw64 -here -c "gcc -shared -o DemoDll-x64.dll DemoDll.cpp"
call C:\msys64\msys2_shell.cmd -mingw32 -here -c "gcc -shared -o DemoDll-x86.dll DemoDll.cpp"

 

 


Quickpost info


3 Comments »

  1. […] Quickpost: Compiling DLLs with MinGW on Windows […]

    Pingback by Overview of Content Published in August | Didier Stevens — Wednesday 5 September 2018 @ 0:00

  2. hey what about sources like “program.cpp” and “program.h” there’s a some config?
    Thanks in advance.

    Comment by Fabian — Saturday 29 October 2022 @ 3:40

  3. This is a series of blog posts. If you follow the links to the previous blog posts, you’ll find the source code: https://blog.didierstevens.com/2017/09/08/quickpost-dlldemo/

    Comment by Didier Stevens — Tuesday 1 November 2022 @ 8:50


RSS feed for comments on this post. TrackBack URI

Leave a Reply (comments are moderated)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.