-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Readme.md and license. Updated Makefile so that it creates the
required output directories. Added resource file for executable.
- Loading branch information
1 parent
7723aaa
commit 422ec40
Showing
6 changed files
with
161 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Ignore compiled binaries | ||
/bin/ | ||
/lib/ | ||
/obj/ | ||
*.exe | ||
*.dll | ||
*.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
# This Makefile will build a DLL and an application using the DLL. | ||
# This Makefile will build a DLL and an application which makes use of the DLL. | ||
|
||
all: AddLib.dll AddTest.exe | ||
# Object files to create for the executable | ||
DLL_OBJS = obj/add.o obj/dllres.o | ||
EXE_OBJS = obj/addtest.o obj/exeres.o | ||
|
||
AddLib.dll: include/add.h | ||
gcc -O3 -std=c99 -D ADD_EXPORTS -Wall -I.\include -c src/add.c -o obj/add.o | ||
windres -i res/resource.rc -o obj/resource.o | ||
gcc -o AddLib.dll obj/add.o obj/resource.o -shared -s -Wl,--subsystem,windows,--out-implib,libaddlib.a | ||
# Warnings to be raised by the C compiler | ||
WARNS = -Wall | ||
|
||
AddTest.exe: include/add.h AddLib.dll | ||
gcc -O3 -std=c99 -Wall -I.\include -c src/addtest.c -o obj/addtest.o | ||
gcc -o AddTest.exe obj/addtest.o -s -L. -lAddLib | ||
# Names of tools to use when building | ||
CC = gcc | ||
RC = windres | ||
EXE = AddTest.exe | ||
DLL = AddLib.dll | ||
|
||
# Compiler flags | ||
EXE_CFLAGS = -O2 -std=c99 ${WARNS} -Iinclude | ||
DLL_CFLAGS = ${EXE_CFLAGS} -D ADD_EXPORTS | ||
|
||
# Linker flags | ||
DLL_LDFLAGS = -shared -s -Wl,--subsystem,windows,--out-implib,lib/libaddlib.a | ||
EXE_LDFLAGS = -Llib -laddlib -s -Wl,--subsystem,console | ||
|
||
.PHONY: all clean | ||
|
||
# Build DLL and executable by default | ||
all: bin/${DLL} bin/${EXE} | ||
|
||
# Delete all build output | ||
clean: | ||
del obj\*.o *.exe *.dll *.a | ||
if exist bin\* del /q bin\* | ||
if exist lib\* del /q lib\* | ||
if exist obj\* del /q obj\* | ||
|
||
# Create build output directories if they don't exist | ||
bin lib obj: | ||
@if not exist "$@" mkdir "$@" | ||
|
||
# Compile object files for DLL | ||
obj/add.o: src/add.c include/add.h | obj | ||
${CC} ${DLL_CFLAGS} -c "$<" -o "$@" | ||
|
||
# Compile object files for executable | ||
obj/addtest.o: src/addtest.c include/add.h | obj | ||
${CC} ${EXE_CFLAGS} -c "$<" -o "$@" | ||
|
||
# Build the resource files | ||
obj/%.o: res/%.rc | obj | ||
${RC} -Iinclude -Ires -i "$<" -o "$@" | ||
|
||
# Build the DLL | ||
bin/${DLL}: ${DLL_OBJS} | bin lib | ||
${CC} -o "$@" ${DLL_OBJS} ${DLL_LDFLAGS} | ||
|
||
# Buld the executable | ||
bin/${EXE}: ${EXE_OBJS} | bin | ||
${CC} -o "$@" ${EXE_OBJS} ${EXE_LDFLAGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# MinGW DLL Example | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
- [Terms of Use](#terms-of-use) | ||
- [Problems?](#problems) | ||
- [Changelog](#changelog) | ||
|
||
## Introduction | ||
|
||
This is an example Win32 DLL and console application. It is intended to demonstrate how to build DLLs using MinGW, and | ||
utilise their functionality within a client application. It accompanies the | ||
[Building Windows DLLs with MinGW](http://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/) article. | ||
|
||
To build the application on a Windows machine, extract the contents of this archive to a folder on your computer. Open a | ||
command prompt, change to the directory where you extracted the files, and type "mingw32-make". The DLL and executable | ||
should be compiled, linked, and output as "AddLib.dll" and "AddTest.exe" in the "bin" directory. The import library will | ||
be created as "libaddlib.a" in the "lib" directory. | ||
|
||
To build under another operating system, the Makefile will probably require some small changes. For example, under | ||
Fedora the 32 bit C compiler and resource compiler are named "i686-w64-mingw32-gcc" and "i686-w64-mingw32-windres". | ||
Also, your version of the make utility may be named differently--please check the documentation which came with your | ||
MinGW packages. | ||
|
||
## Terms of Use | ||
|
||
Refer to "License.txt" for terms of use. | ||
|
||
## Problems? | ||
|
||
If you have any problems or questions, please ensure you have read this readme | ||
file and the | ||
[Building Windows DLLs with MinGW](http://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/) | ||
article. If you are still having trouble, you can | ||
[get in contact](http://www.transmissionzero.co.uk/contact/). | ||
|
||
## Changelog | ||
|
||
2. 2013-08-26: Version 1.1 | ||
- Minor tweaks to the VERSIONINFO resource so that it uses constants rather than magic numbers. | ||
|
||
1. 2011-04-16: Version 1.0 | ||
- First release. | ||
|
||
Transmission Zero | ||
2017-11-10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <windows.h> | ||
|
||
// DLL version information. | ||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION 1,0,0,0 | ||
PRODUCTVERSION 1,0,0,0 | ||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
#ifdef _DEBUG | ||
FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE | ||
#else | ||
FILEFLAGS 0 | ||
#endif | ||
FILEOS VOS_NT_WINDOWS32 | ||
FILETYPE VFT_APP | ||
FILESUBTYPE VFT2_UNKNOWN | ||
BEGIN | ||
BLOCK "StringFileInfo" | ||
BEGIN | ||
BLOCK "080904b0" | ||
BEGIN | ||
VALUE "CompanyName", "Transmission Zero" | ||
VALUE "FileDescription", "Application which uses the Addition Library." | ||
VALUE "FileVersion", "1.0.0.0" | ||
VALUE "InternalName", "AddTest" | ||
VALUE "LegalCopyright", "�2017 Transmission Zero" | ||
VALUE "OriginalFilename", "AddTest.exe" | ||
VALUE "ProductName", "Addition Test" | ||
VALUE "ProductVersion", "1.0.0.0" | ||
END | ||
END | ||
BLOCK "VarFileInfo" | ||
BEGIN | ||
VALUE "Translation", 0x809, 1200 | ||
END | ||
END |