Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mingw/msys support #19

Merged
merged 1 commit into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build/gmake_windows/test_opendialog.make
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifeq ($(config),release_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x64/nfd.lib
LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x64/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -49,7 +49,7 @@ ifeq ($(config),release_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x86/nfd.lib
LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x86/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand Down
8 changes: 4 additions & 4 deletions build/gmake_windows/test_opendialogmultiple.make
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifeq ($(config),release_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x64/nfd.lib
LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x64/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -49,7 +49,7 @@ ifeq ($(config),release_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x86/nfd.lib
LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x86/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand Down
8 changes: 4 additions & 4 deletions build/gmake_windows/test_savedialog.make
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifeq ($(config),release_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x64/nfd.lib
LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x64/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -49,7 +49,7 @@ ifeq ($(config),release_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x86/nfd.lib
LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid
LDDEPS += ../lib/Release/x86/nfd.lib
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand All @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LIBS += -lnfd_d -lole32 -luuid
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
Expand Down
5 changes: 4 additions & 1 deletion build/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ local make_test = function(name)

filter {"configurations:Debug", "system:linux"}
linkoptions {"-lnfd_d `pkg-config --libs gtk+-3.0`"}


filter {"action:gmake", "system:windows"}
links {"ole32", "uuid"}

end

make_test("test_opendialog")
Expand Down
11 changes: 8 additions & 3 deletions src/nfd_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
#define UNICODE
#endif

#ifdef __MINGW32__
// Explicitly setting NTDDI version, this is necessary for the MinGW compiler
#define NTDDI_VERSION NTDDI_VISTA
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#endif

#include <wchar.h>
#include <stdio.h>
#include <assert.h>
#include <atlbase.h>
#include <windows.h>
#include <ShObjIdl.h>

Expand Down Expand Up @@ -360,14 +364,15 @@ nfdresult_t NFD_OpenDialog( const char *filterList,
HRESULT result = ::CoInitializeEx(NULL,
::COINIT_APARTMENTTHREADED |
::COINIT_DISABLE_OLE1DDE );

::IFileOpenDialog *fileOpenDialog(NULL);

if ( !SUCCEEDED(result))
{
NFDi_SetError("Could not initialize COM.");
goto end;
}

::IFileOpenDialog *fileOpenDialog(NULL);

// Create dialog
result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL,
CLSCTX_ALL, ::IID_IFileOpenDialog,
Expand Down