Permalink
Browse files

windows: fix build with mingw64

tested ok with curl-7.38.0 openssl 1.0.1j

was really not easy to setup, ssl config:

 CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure mingw64 no-asm no-shared
 make && make install

curl config:

 extraopts=--enable-ipv6
 extraflags="-DOPENSSL_NO_ASM -D_THREAD_SAFE"
 openssl=/usr/local/ssl
 CROSS_COMPILE="x86_64-w64-mingw32-" ./configure --enable-shared=no \
 --disable-manual --without-libssh2 --disable-rtsp --disable-ldap \
 --disable-dict --disable-pop3 --disable-ftp --disable-telnet --disable-tftp \
 --disable-smtp --disable-imap --disable-ldaps --disable-gopher --with-zlib \
 --with-ssl=$openssl --with-libssl-prefix=$openssl CPPFLAGS="$extraflags" ${extraopts}

Signed-off-by: Tanguy Pruvot
  • Loading branch information...
1 parent 588f5d9 commit 3967e06337be41321a92194722b9dccfcb9ffad2 unknown committed with Oct 30, 2014
Showing with 113 additions and 41 deletions.
  1. +1 −0 .gitignore
  2. +9 −3 Makefile.am
  3. +4 −0 README.md
  4. +2 −1 autogen.sh
  5. BIN compat/pthreads/x64/libpthreadGC2.a
  6. +75 −27 configure.ac
  7. +3 −3 cpu-miner.c
  8. +0 −1 cpuminer.vcxproj
  9. +0 −3 cpuminer.vcxproj.filters
  10. +4 −3 crypto/int-util.h
  11. +7 −0 cryptonight.c
  12. +8 −0 mingw64.sh
View
@@ -37,3 +37,4 @@ Release/
Debug/
x64/Release/
x64/Debug/
+*.pdb/
View
@@ -5,11 +5,13 @@ else
JANSSON_INCLUDES=
endif
+ACLOCAL_AMFLAGS = -I m4
+
EXTRA_DIST = example-cfg.json nomacro.pl
SUBDIRS = compat
-INCLUDES = $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES)
+INCLUDES = @PTHREAD_FLAGS@ -fno-strict-aliasing $(JANSSON_INCLUDES)
bin_PROGRAMS = minerd
@@ -75,10 +77,14 @@ if ARCH_ARM
endif
endif
-minerd_LDFLAGS = $(PTHREAD_FLAGS)
+if HAVE_WINDOWS
+ minerd_SOURCES += compat/winansi.c
+endif
+
+minerd_LDFLAGS = @LDFLAGS@
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@
minerd_CPPFLAGS = @LIBCURL_CPPFLAGS@
-minerd_CFLAGS = -Wno-pointer-sign -O3
+minerd_CFLAGS = -Wno-pointer-sign
if HAVE_WINDOWS
minerd_CFLAGS += -Wl,--stack,10485760
View
@@ -71,6 +71,10 @@ Build
* To build a 64-bit binary, export OBJECT_MODE=64
* GNU-style long options are not supported, but are accessible via configuration file
+#### Basic Windows build with Visual Studio 2013
+ * All the required .lib files are now included in tree (windows only)
+ * AVX enabled by default, but not AVX2 (edit cpu-miner-config.h if required)
+
#### Basic Windows build instructions, using MinGW:
* Install MinGW and the MSYS Developer Tool Kit (http://www.mingw.org/)
* Make sure you have mstcpip.h in MinGW\include
View
@@ -7,6 +7,7 @@ set -e
aclocal
autoheader
-automake --gnu --add-missing --copy
+automake --foreign --add-missing --force-missing --copy
+# automake --gnu --add-missing --copy
autoconf
Binary file not shown.
View
@@ -1,10 +1,12 @@
-AC_INIT([cpuminer], [1.0.5])
+AC_INIT([cpuminer-multi], [1.0.5])
AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([cpu-miner.c])
-AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_HEADERS([cpuminer-config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([foreign subdir-objects])
dnl Make sure anyone changing configure.ac/Makefile.am has a clue
AM_MAINTAINER_MODE
@@ -15,6 +17,7 @@ AC_PROG_GCC_TRADITIONAL
AM_PROG_CC_C_O
AM_PROG_AS
AC_PROG_RANLIB
+# AC_PROG_CXX
dnl Checks for header files
AC_HEADER_STDC
@@ -38,26 +41,31 @@ AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], [],
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([getopt_long])
-case $target in
- i*86-*-*)
+MINGW_TARGET=`$CC -dumpmachine 2>&1`
+case $MINGW_TARGET in
+ arm*-*-*)
+ have_arm=true
+ ;;
+ i*86-*-mingw*)
have_x86=true
+ have_win32=true
+ CFLAGS="-Icompat/pthreads $CFLAGS"
+ PTHREAD_LDFLAGS="-Lcompat/pthreads/x86"
+ WS2_LIBS="-lws2_32 -fPIC"
;;
- x86_64-*-*|amd64-*-*)
+ x86_64-*-mingw*|amd64-*-mingw*)
have_x86_64=true
+ have_win32=true
+ CFLAGS="-Icompat/pthreads $CFLAGS"
+ PTHREAD_LDFLAGS="-Lcompat/pthreads/x64"
+ # SHOULD BE AT END! after -lcrypto #
+ WS2_LIBS="-L/mingw/x86_64-w64-mingw32/lib -lws2_32 -fPIC"
;;
- arm*-*-*)
- have_arm=true
+ i*86-*-*)
+ have_x86=true
;;
-esac
-
-PTHREAD_FLAGS="-pthread"
-WS2_LIBS=""
-
-case $target in
- *-*-mingw*)
- have_win32=true
- PTHREAD_FLAGS=""
- WS2_LIBS="-lws2_32"
+ x86_64-*-*|amd64-*-*)
+ have_x86_64=true
;;
esac
@@ -96,13 +104,17 @@ then
fi
AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
-AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread",
- AC_CHECK_LIB([pthreadGC2], [pthread_create], PTHREAD_LIBS="-lpthreadGC2",
- AC_CHECK_LIB([pthreadGC1], [pthread_create], PTHREAD_LIBS="-lpthreadGC1",
- AC_CHECK_LIB([pthreadGC], [pthread_create], PTHREAD_LIBS="-lpthreadGC"
-))))
-AC_CHECK_LIB([crypto], [OPENSSL_init], [], [AC_MSG_FAILURE([could not find crypto])])
+# GC2 for GNU static
+if test "x$OS" = "xWindows_NT" ; then
+ # MinGW
+ AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthreadGC2",[])
+else
+ AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread",[])
+fi
+
+LDFLAGS="$PTHREAD_LDFLAGS $LDFLAGS"
+# PTHREAD_LIBS="$PTHREAD_LIBS"
AC_MSG_CHECKING(whether __uint128_t is supported)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([static __uint128_t i = 100;])],
@@ -112,22 +124,58 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([static __uint128_t i = 100;])],
AC_MSG_RESULT(no)
)
+# allow if <var> in Makefile.am
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
AM_CONDITIONAL([USE_ASM], [test x$enable_assembly != xno])
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue])
+AM_CONDITIONAL([MINGW], [test "x$OS" = "xWindows_NT"])
-if test x$request_jansson = xtrue
-then
+if test x$request_jansson = xtrue ; then
JANSSON_LIBS="compat/jansson/libjansson.a"
else
JANSSON_LIBS=-ljansson
fi
-LIBCURL_CHECK_CONFIG(, 7.15.2, ,
- [AC_MSG_ERROR([Missing required libcurl >= 7.15.2])])
+# libcurl install path (for mingw : --with-curl=/usr/local)
+AC_ARG_WITH([curl],
+ [ --with-curl=PATH prefix where curl is installed [default=/usr]])
+
+if test -n "$with_curl" ; then
+ LIBCURL_CFLAGS="$LIBCURL_CFLAGS -I$with_curl/include"
+ LIBCURL_LDFLAGS="-L$with_curl/lib $LIBCURL_LDFLAGS"
+ LIBCURL="-lcurl -lz"
+fi
+
+# SSL install path (for mingw : --with-crypto=/usr/local/ssl)
+AC_ARG_WITH([crypto],
+ [ --with-crypto=PATH prefix where openssl crypto is installed [default=/usr]])
+
+if test -n "$with_crypto" ; then
+ LIBCURL_CFLAGS="$LIBCURL_CFLAGS -I$with_crypto/include"
+ LIBCURL_LDFLAGS="-L$with_crypto/lib $LIBCURL_LDFLAGS"
+ LIBCURL="$LIBCURL -lssl -lcrypto"
+fi
+
+CFLAGS="$CFLAGS $LIBCURL_CFLAGS"
+LDFLAGS="$LDFLAGS $LIBCURL_LDFLAGS"
+
+#AC_CHECK_LIB([crypto],[OPENSSL_init], crypto=yes, [AC_MSG_ERROR([OpenSSL crypto library required])])
+#AC_CHECK_LIB([ssl],[SSL_new], ssl=yes, ssl=no)
+
+# AC_CHECK_LIB([curl], [curl_multi_timeout],
+# have_libcurl=yes,
+# have_libcurl=no AC_MSG_ERROR([curl library required])
+# )
+
+# LIBCURL_CHECK_CONFIG([yes], 7.15, curlconfig=yes, curlconfig=no)
+
+AC_SUBST(LIBCURL)
+AC_SUBST(LIBCURL_CFLAGS)
+AC_SUBST(LIBCURL_CPPFLAGS)
+# AC_SUBST(LIBCURL_LDFLAGS)
AC_SUBST(JANSSON_LIBS)
AC_SUBST(PTHREAD_FLAGS)
View
@@ -2526,11 +2526,11 @@ static void show_credits()
{
printf(PROGRAM_NAME " by Lucas Jones and Tanguy Pruvot\n");
#ifdef _MSC_VER
- printf(CL_GRY " This is version " PACKAGE_VERSION " built with VC++ 2013\n" CL_N);
+ printf(CL_GRY " This is version " PACKAGE_VERSION ", built with VC++ 2013" CL_N "\n");
#else
- printf(" This is version " PACKAGE_VERSION "\n");
+ printf(CL_GRY " This is version " PACKAGE_VERSION CL_N "\n");
#endif
- printf(CL_GRY " based on pooler/cpuminer 2.4 (c) 2010 Jeff Garzik, 2012 pooler\n" CL_N);
+ printf(CL_GRY " based on pooler cpuminer 2.4" CL_N "\n");
}
int main(int argc, char *argv[]) {
View
@@ -289,7 +289,6 @@
<ClInclude Include="sha3\sph_hamsi.h" />
<ClInclude Include="sha3\sph_types.h" />
<ClInclude Include="sha3\sph_whirlpool.h" />
- <ClInclude Include="uint256.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="neoscrypt_asm.S">
@@ -223,9 +223,6 @@
<ClInclude Include="compat\sys\time.h">
<Filter>compat</Filter>
</ClInclude>
- <ClInclude Include="uint256.h">
- <Filter>compat</Filter>
- </ClInclude>
<ClInclude Include="compat\unistd.h">
<Filter>compat</Filter>
</ClInclude>
View
@@ -8,13 +8,14 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
-#ifdef HAVE_SYS_PARAM_H
+#ifndef _MSC_VER
#include <sys/param.h>
+#else
+#define inline __inline
#endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
#include <stdlib.h>
-#define inline __inline
//#define IS_LITTLE_ENDIAN (1 == *(unsigned char *)&(const int){1})
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
View
@@ -5,6 +5,7 @@
// Modified for CPUminer by Lucas Jones
#include "cpuminer-config.h"
+
#include "miner.h"
#include "crypto/oaes_lib.h"
#include "crypto/c_keccak.h"
@@ -15,6 +16,12 @@
#include "crypto/int-util.h"
#include "crypto/hash-ops.h"
+#if USE_INT128 && defined(_MSC_VER)
+/* only for mingw64 on windows */
+#undef USE_INT128
+#define USE_INT128 (0)
+#endif
+
#if USE_INT128
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ < 6
View
@@ -0,0 +1,8 @@
+./autogen.sh
+
+CURL_PREFIX=/usr/local
+SSL_PREFIX=/usr/local/ssl
+
+CFLAGS="-O3 -DCURL_STATICLIB -DOPENSSL_NO_ASM"
+
+./configure --build=x86_64-w64-mingw32 --with-crypto=$SSL_PREFIX --with-curl=$CURL_PREFIX CFLAGS="$CFLAGS"

0 comments on commit 3967e06

Please sign in to comment.