summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-10-27 13:17:57 +0100
committerPete Batard <pbatard@gmail.com>2010-10-27 13:17:57 +0100
commit98c3552705036e1fba72d62be82541acf2b8d91f (patch)
tree0235ba95fdbe2858cc8ee79be17ef59fd45452cc
parent86cf94cfdcc9379641ed6d47f98dd2e602eac5ac (diff)
downloadlibusb-98c3552705036e1fba72d62be82541acf2b8d91f.tar.gz
added /MT option for DDK builds
* default for ddk was to use MSVCRT, which produces static libs that cannot be used in MSVC with /MT (libcmt) * ddk_build script now allows users to chose between /MD and /MT compatibility * also simplified libusb_sources and updated INSTALL_WIN.txt
-rw-r--r--INSTALL_WIN.txt13
-rw-r--r--ddk_build.cmd23
-rw-r--r--examples/lsusb_sources5
-rw-r--r--examples/xusb_sources5
-rw-r--r--libusb/os/libusb_sources6
5 files changed, 32 insertions, 20 deletions
diff --git a/INSTALL_WIN.txt b/INSTALL_WIN.txt
index f56b6c2..778f891 100644
--- a/INSTALL_WIN.txt
+++ b/INSTALL_WIN.txt
@@ -5,8 +5,8 @@ If you are compiling for MinGW or cygwin, please refer to the INSTALL file.
If you are using Microsoft Visual Studio:
- Open the relevant solution file libusb.dsw for MSVC6, libusb.sln for Visual
- Studio 2005 or later (you will go through a short conversion process if using
- 2008)
+ Studio 2005 or later (you will go through a conversion process if using 2008
+ or later)
- If you want to debug the library, uncomment the ENABLE_DEBUG_LOGGING define
in config.h
- Select your configuration and compile the project
@@ -22,6 +22,8 @@ If you are using the freely available Windows DDK/WDK (Driver Development Kit)
- Navigate to the root directory of the distribution, where the ddk_build.cmd
file is located, and run 'ddk_build'
- To produce a DLL rather than a static library, use: 'ddk_build DLL'
+- To produce a static library that uses LIBCMT[d] instead of MSVCRT[d] (/MT[d]
+ vs /MD[d] in Visual Studio) use: 'ddk_build /MT'
Note that using the Windows DDK, it is possible to compile both the 32 and 64
bit versions of the library.
@@ -40,15 +42,10 @@ Troubleshooting
If the compilation process complains about missing libraries, you need to ensure
that the default library paths for your project point to a directory that
-contains setupapi.lib and ole32.lib.
+contains the necessary libraries.
If needed, these libraries can be obtained by installing either the latest
Windows SDK or the DDK (Links provided at the end of this file).
-The 64 bit version of the library has been tested at least as much as the 32 bit
-version during development. Same goes for Windows 7 vs Vista/XP.
-Therefore we do not expect specific issues related to using these targets with
-libusb.
-
Links
*****
diff --git a/ddk_build.cmd b/ddk_build.cmd
index 88d3c25..0444187 100644
--- a/ddk_build.cmd
+++ b/ddk_build.cmd
@@ -1,20 +1,23 @@
+@rem default builds static library.
+@rem you can pass the following arguments (case insensitive):
+@rem - "DLL" to build a DLL instead of a static library
+@rem - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT)
@echo off
-rem default builds static library. Pass argument 'DLL' to build a DLL
-
if Test%BUILD_ALT_DIR%==Test goto usage
+rem process commandline parameters
+set TARGET=LIBRARY
+set STATIC_LIBC=
set version=1.0
+if "%1" == "" goto no_more_args
+rem /I for case insensitive
+if /I Test%1==TestDLL set TARGET=DYNLINK
+if /I Test%1==Test/MT set STATIC_LIBC=1
+:no_more_args
+
cd libusb\os
-rem DLL or static lib selection (must use concatenation)
-if Test%1==TestDLL goto libusb_dll
-:libusb_static
-set TARGET=LIBRARY
-goto libusb_common
-:libusb_dll
-set TARGET=DYNLINK
-:libusb_common
echo TARGETTYPE=%TARGET% > target
copy target+libusb_sources sources >NUL 2>&1
del target
diff --git a/examples/lsusb_sources b/examples/lsusb_sources
index 8600180..ed7fe74 100644
--- a/examples/lsusb_sources
+++ b/examples/lsusb_sources
@@ -7,7 +7,12 @@ _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
MSC_WARNING_LEVEL=/W3
!ENDIF
+!IFDEF STATIC_LIBC
+USE_LIBCMT=1
+!ELSE
USE_MSVCRT=1
+!ENDIF
+
UMTYPE=console
INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
diff --git a/examples/xusb_sources b/examples/xusb_sources
index f7bd1a0..ea1b8f4 100644
--- a/examples/xusb_sources
+++ b/examples/xusb_sources
@@ -8,7 +8,12 @@ _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
MSC_WARNING_LEVEL=/W3
!ENDIF
+!IFDEF STATIC_LIBC
+USE_LIBCMT=1
+!ELSE
USE_MSVCRT=1
+!ENDIF
+
UMTYPE=console
INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
diff --git a/libusb/os/libusb_sources b/libusb/os/libusb_sources
index 5653476..5aa8b87 100644
--- a/libusb/os/libusb_sources
+++ b/libusb/os/libusb_sources
@@ -6,7 +6,11 @@ DLLDEF=..\libusb-1.0.def
MSC_WARNING_LEVEL=/W3
!ENDIF
+!IFDEF STATIC_LIBC
+USE_LIBCMT=1
+!ELSE
USE_MSVCRT=1
+!ENDIF
INCLUDES=..;..\..\msvc;$(DDK_INC_PATH)
C_DEFINES= $(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD
@@ -20,8 +24,6 @@ C_DEFINES= $(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD
# an older compiler than other objects; rebuild old objects and libraries"
USER_C_FLAGS=/GL-
-TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib
-
SOURCES=..\core.c \
..\descriptor.c \
..\io.c \