From e6c6c16d564bb4bb8cfe9842dd55b7cdc89e932e Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sat, 16 Dec 2017 13:19:34 -0500 Subject: [PATCH] [host] compile NvFBC on mingw --- host/Capture/NvFBC.cpp | 2 +- host/Makefile | 6 +++++- host/Util.h | 12 +++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/host/Capture/NvFBC.cpp b/host/Capture/NvFBC.cpp index 3d21b069..14308b11 100644 --- a/host/Capture/NvFBC.cpp +++ b/host/Capture/NvFBC.cpp @@ -65,7 +65,7 @@ bool NvFBC::Initialize(CaptureOptions * options) m_hDLL = LoadLibraryA(nvfbc.c_str()); if (!m_hDLL) { - DEBUG_ERROR("Failed to load the NvFBC library: %d - %s", GetLastError(), nvfbc.c_str()); + DEBUG_ERROR("Failed to load the NvFBC library: %d - %s", (int)GetLastError(), nvfbc.c_str()); return false; } diff --git a/host/Makefile b/host/Makefile index 930034b2..9689c386 100644 --- a/host/Makefile +++ b/host/Makefile @@ -16,7 +16,6 @@ LD = $(CXX) BUILD ?= .build BIN ?= bin -#CFLAGS += -DCONFIG_CAPTURE_NVFBC=1 CFLAGS += -DBUILD_VERSION='"$(shell git describe --always --long --dirty --abbrev=10 --tags)"' @@ -26,6 +25,11 @@ OBJS = main.o \ Service.o \ Capture/DXGI.o +ifeq ($(CONFIG_CAPTURE_NVFBC),1) +CFLAGS += -DCONFIG_CAPTURE_NVFBC=1 -I../vendor +OBJS += Capture/NvFBC.o +endif + BUILD_OBJS = $(foreach obj,$(OBJS),$(BUILD)/$(obj)) all: $(BIN)/$(BINARY) diff --git a/host/Util.h b/host/Util.h index b7db3d9e..3e75ec8e 100644 --- a/host/Util.h +++ b/host/Util.h @@ -23,8 +23,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include -#include "common\debug.h" +#include "common/debug.h" +#if __MINGW32__ +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif class Util { @@ -33,16 +36,15 @@ public: { std::string defaultPath; - size_t pathSize; - char *libPath; + const char *libPath = getenv("SystemRoot"); - if (_dupenv_s(&libPath, &pathSize, "SystemRoot") != 0) + if (!libPath) { DEBUG_ERROR("Unable to get the SystemRoot environment variable"); return defaultPath; } - if (!pathSize) + if (!strlen(libPath)) { DEBUG_ERROR("The SystemRoot environment variable is not set"); return defaultPath;