Skip to content

Instantly share code, notes, and snippets.

@romiras romiras/Makefile.win
Created Jan 13, 2016

Embed
What would you like to do?
TestDLL.exe - console program for testing DLL dependencies. Usage: testdll.exe libcairo-2.dll
#include <windows.h>
#include <stdio.h>
/*
__declspec(dllexport) FARPROC Test() {
printf("It worked");
}
*/
void what_error(DWORD res) {
wchar_t buf[256];
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, res,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 256, NULL);
printf("%s\n", buf);
}
void WinErr(const char *Msg, DWORD ErrorCode)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL);
printf("%s. %s\n", Msg, lpMsgBuf);
LocalFree(lpMsgBuf);
}
int main(int argc, char **argv) {
HMODULE m = LoadLibrary(argv[1]);
/*
FARPROC test = GetProcAddress(m, "Test");
test();
*/
if (m != 0) {
BOOL b;
b = FreeLibrary(m);
puts("OK");
}
else {
DWORD res = GetLastError();
printf("Cannot load %s. Code: %d\n", argv[1], res);
/*what_error(res);*/
WinErr("Oops", res);
}
return 0;
}
# Project: TestDLL
# Makefile created by Dev-C++ 5.5.1
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"C:/Program Files/Development/Dev-Cpp/MinGW32/lib" -L"C:/Program Files/Development/Dev-Cpp/MinGW32/mingw32/lib" -static-libstdc++ -static-libgcc
INCS = -I"C:/Program Files/Development/Dev-Cpp/MinGW32/include"
CXXINCS = -I"C:/Program Files/Development/Dev-Cpp/MinGW32/include" -I"C:/Program Files/Development/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.7.2/include/c++"
BIN = testdll.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)
main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.