MingGW Makefile for Win32++ samples and tutorials


Quoting directly from the SourceForge project description, “Win32++ is a C++ library used to build windows applications. It supports most compilers including Visual Studio Community 2015”.
However there is no plain MinGW makefile provided for the sample programs.

You can use the following Makefile to compile the examples from the Win32++ download page

Just create a file named “Makefile” in the src folder of any of the samples, or directly in the tutorial folder. Make sure you set the number of folders back for the INCLUDE_DIRS which may be either two or three folders back.
i.e. ../../include or ../../../include

Also note, almost every library under the sun is included in the LDFLAGS, just to make sure all the samples are compiled and linked without error.

APP=main
EXECUTABLE=$(APP).exe
INCLUDE_DIRS=-I ../../include

CC="c:\MinGW\bin\g++.exe"
LDFLAGS=-lgdi32 -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lcomctl32 -lcomdlg32 -lOleAut32 -lole32 -luuid -lws2_32 

RC=windres

src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)

#obj/%.o: src/%.cpp ${HEADERS}
%.o: %.cpp
	${CC} ${CFLAGS} ${INCLUDE_DIRS} -c $< -o $@

all: resource.res $(EXECUTABLE)

$(EXECUTABLE): $(obj)
	$(CC) -o $(EXECUTABLE) $^ $(LDFLAGS) resource.res

resource.res: Resource.rc
	${RC} Resource.rc $(INCLUDE_DIRS) -O coff -o resource.res

.PHONY: clean
clean:
	del $(EXECUTABLE) $(obj) *.res

To compile and run the samples, enter the following from the command line:

c:\MinGW\bin\mingw32-make.exe all
main.exe
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s