[XPM][WIN] Compiling beeeeer.org miner on Windows

Ok, after hours of works i finally compiled primeminer under windows!!! You may ask why I’m spending 3 hours in compiling it when there are already binaries there around…well there are two reasons, the first is that i don’t trust binaries w/o source code and the second is performance.
Yes, performance!!! Compiling my own primeminer i got a 5% performance improvement (tnx to gmp optimizations)!!

Anyway any donation is welcome!! (I may be persuaded to create an automatic installer :P)
AGgPQKp7YAau1zUZqf6Pxqr3dnqoEqyBCm

[hr]

[b]

  1. Prepare your build system.[/b]

1.1 Install msys:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download
Leave default location (C:\MinGW)
move to C:\MinGW\bin and run mingw-get
Select “basic setup -> msys-base package”
and “All Packages -> msys-m4”.
Then click on Installation -> Apply Changes.

1.2 Install Perl:
http://downloads.activestate.com/ActivePerl/releases/5.18.1.1800/ActivePerl-5.18.1.1800-MSWin32-x86-64int-297570.msi
Run installer and exclude Perl Script, PPM, documentation and examples if you don’t need them for other purposes.

1.3 Install Python:
http://www.python.org/ftp/python/3.3.2/python-3.3.2.amd64.msi
Leave defaults values.

1.4 Install GCC from mingw-builds:
Download http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-posix/dwarf/x32-4.8.1-release-posix-dwarf-rev5.7z/download
Then unpack it in C: (you will obtain a C:\mingw32 folder)

1.5. Ensure that mingw-builds, Perl and Python bin folders are set in your PATH environment variable.
Open cmd and write echo %path%
insert missing path using those commands (avoid those for wich path already exists)

SET PATH=%PATH%;"C:\Perl\site\bin" SET PATH=%PATH%;"C:\Perl\bin" SET PATH=%PATH%;"C:\mingw32\bin" SET PATH=%PATH%;"C:\Pyton33"


2. Download, unpack and build required dependencies.

Create a new folder: C:\deps
All file downloaded in that session have to be placed there.

2.1 OpenSSL: http://www.openssl.org/source/openssl-1.0.1c.tar.gz
From a MinGw shell (C:\MinGW\msys\1.0\msys.bat), unpack the source archive with tar then configure and make:

cd /c/deps/
tar xvfz openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./config
make

2.2 Berkeley DB: http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
From a MinGW shell unpack the source archive, configure, edit line 113 of db.h then make:

cd /c/deps/
tar xvfz db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --disable-replication --enable-mingw --enable-cxx

after configuring make sure to edit your C:\deps\db-4.8.30.NC\build_unix\db.h by replacing line 113:

typedef pthread_t db_threadid_t;

with

typedef u_int32_t db_threadid_t;

Thanks to Icy, see: https://bitcointalk.org/index.php?topic=45507.0

now you can:

make
make install

2.3 Boost: http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz/download
From a MinGW shell unpack the source archive, then bootstrap and compile from a Windows command prompt:

cd /c/deps/
tar xvfz boost_1_54_0.tar.gz

Open a Windows command prompt (Start -> Run -> cmd.exe)

cd C:\deps\boost_1_54_0\
bootstrap.bat mingw
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc stage

This will compile the required boost libraries and put them into the stage folder (C:\deps\boost_1_54_0\stage).

2.4 Miniupnpc: http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz
From a MinGW shell unpack the source archive, then make

cd /c/deps/
tar xvfz miniupnpc-1.8.tar.gz

Move to C:\deps\miniupnpc-1.8 folder, double click on mingw32make.bat.

2.5 GMP: https://gmplib.org/download/gmp/gmp-5.1.2.tar.xz
From a MinGW shell unpack the source archive, configure, make and install

cd /c/deps/
tar xvfJ gmp-5.1.2.tar.xz
cd gmp-5.1.2
./configure --prefix=/c/deps/gmp/ --enable-cxx --with-gnu-ld
make
make install

3. Download Primecoin miner for beeeeer.org from git, compile leveldb then compile primeminer https://github.com/thbaumbach/primecoin/archive/master.zip (specific build version of that guide here, rename that zip into master.zip)
Leveldb libraries will not compile automatically so we’ll need to compile them first.

3.1 Extract master.zip (for example to C:) then start MinGW shell and change into leveldb folder:

cd /C/master/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a

3.2 Now with a texteditor edit BOOST_SUFFIX, INCLUDEPATHS and LIBPATHS in your C:\master\src\makefile.mingw according to your dependencies location and correct $(CURDIR) error:

BOOST_SUFFIX?=-mgw48-mt-s-1_54

INCLUDEPATHS= \
 -I"$(CURDIR)" \
 -I"c:/deps/boost_1_54_0" \
 -I"C:/deps/db-4.8.30.NC/build_unix" \
 -I"c:/deps/openssl-1.0.1c/include" \
 -I"c:/deps/gmp/include"
 
LIBPATHS= \
 -L"$(CURDIR)/leveldb" \
 -L"c:/deps/boost_1_54_0/stage/lib" \
 -L"C:/deps/db-4.8.30.NC/build_unix" \
 -L"c:/deps/openssl-1.0.1c" \
 -L"c:/deps/gmp/lib"

If using a gcc version different from 4.8.x change appropriately BOOST_SUFFIX?=-mgw##-mt-s-1_54

Then in the same file also add quotes as in the code

#
# LevelDB support
#
DEFS += $(addprefix -I,"$(CURDIR)/leveldb/include")
DEFS += $(addprefix -I,"$(CURDIR)/leveldb/helpers")

3.3 net.cpp will need to be patched in order to compile with gcc 4.8.1:
Fix invalid conversion error with MinGW 4.8.1 in net.cpp
Open C:\master\src\net.cpp and edit those lines
search for

setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));

and substitute with

#ifdef WIN32
        setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
         setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif

bug reference

3.4 Compile everything and create your .exe
From a Windows command prompt run:

cd C:\master\src
mingw32-make -f makefile.mingw
strip primeminer.exe

The program is ready to be used!!

4. Launch the program and profit!

primeminer -poolip=54.200.248.75 -poolport=1337 -pooluser=AGgPQKp7YAau1zUZqf6Pxqr3dnqoEqyBCm -poolpassword=PASSWORD -poolfee=1 -proclimit=2

Obviously set it with your data!

Well, I tried. For hours. All seems to go well until the last step.

c:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgmp collect2.exe: error: ld returned 1 exit status makefile.mingw:135: recipe for target 'primeminer.exe' failed mingw32-make.exe: *** [primeminer.exe] Error 1

I should also note that for the makefile there’s this:

[code]INCLUDEPATHS=
-I"$(CURDIR)"
-I"c:/deps/boost_1_54_0"
-I"C:/deps/db-4.8.30.NC/build_unix"
-I"c:/deps/openssl-1.0.1c/include"
-I"c:/deps/gmp/include"

LIBPATHS=
-L"$(CURDIR)/leveldb"
-L"c:/deps/boost_1_54_0/stage/lib"
-L"C:/deps/db-4.8.30.NC/build_unix"
-L"c:/deps/openssl-1.0.1c"
-L"c:/deps/gmp/lib"[/code]

and I have to do this to get it to even try and compile:

[code]INCLUDEPATHS=
-I"$(CURDIR)"
-I"c:/deps/boost_1_54_0"
-I"C:/deps/db-4.8.30.NC/build_unix"
-I"c:/deps/openssl-1.0.1c/include"
-I"c:/deps/gmp/include"

LIBPATHS=
-L"$(CURDIR)/leveldb"
-L"c:/deps/boost_1_54_0/stage/lib"
-L"C:/deps/db-4.8.30.NC/build_unix"
-L"c:/deps/openssl-1.0.1c"

-L"c:/deps/gmp/lib"[/code]

Note the # -L"c:/deps/gmp/lib", it’ll otherwise say:

C:\master\src>mingw32-make.exe -f makefile.mingw mingw32-make.exe: Nothing to be done for '-L"c'.

After reading above a bit more I noticed I didn’t try messing with the portion that reads this: (specific build version of that guide here, rename that zip into master.zip) … I guess I’ll try that ver tomorrow.

Has me beat for now. I’m simply exhausted. Zzzz …

haven’t checked it myself, but it looks good!

the mingw setup is really painful!!

thank you for your effort!!!

[quote=“kalup, post:1, topic:1110”]two reasons, the first is that i don’t trust binaries w/o source code and the second is performance.
Yes, performance!!! Compiling my own primeminer i got a 5% performance improvement (tnx to gmp optimizations)!![/quote]
no source code? ???

and i dont understand why your setup should give you 5% performance boost as there’s no significant difference to my setup.

anyway, good work, thank you.

  • xolokram

@Zor Prime: my bad, i’ve forgot a “” in LIBPATH

that is the correct code (corrected in the first post, thanks for the alert! :wink: )

BOOST_SUFFIX?=-mgw48-mt-s-1_54

INCLUDEPATHS= \
 -I"$(CURDIR)" \
 -I"c:/deps/boost_1_54_0" \
 -I"C:/deps/db-4.8.30.NC/build_unix" \
 -I"c:/deps/openssl-1.0.1c/include" \
 -I"c:/deps/gmp/include"
 
LIBPATHS= \
 -L"$(CURDIR)/leveldb" \
 -L"c:/deps/boost_1_54_0/stage/lib" \
 -L"C:/deps/db-4.8.30.NC/build_unix" \
 -L"c:/deps/openssl-1.0.1c" \
 -L"c:/deps/gmp/lib"

@xolokram what processor did you use during the compiling of your exe file? (are the exe files that spread around forums yours? Those in which there is a *edit-me.bat file?)
what family of processor did you set as “-host” in the GMP lib compilation? Because compiling on my own let GMP do his best in tweaking code with asm to reach highest performances as possible!!

i’m using a sandy bridge core i5
i didnt set a specific -host target, just like in your instructions
mh, i should check that again, maybe i missed something there

  • xolokram

Well, I got it compiled.

I went from 1.6 chains/day to 1.0

:-\

(Phenom processor)

I figured I had done something wrong so I went back and used the makefile.mingw64 file. No real difference.

I tried to use https://github.com/thbaumbach/primecoin/archive/eae386c0b20d3af615e9d55f18ff30adf8cee0be.zip and it will compile, but it throws this error after starting:

[code]C:\beeer\src>primeminer.bat

C:\beeer\src>primeminer.exe -poolip=54.200.248.75 -poolport=1337 -pooluser=AcuHsC1UbQC29VqMXCppHm63pcurzNbiJp
-poolpassword=a1b2c3d4e5 -genproclimit=6
GeneratePrimeTable() : setting nRoundSievePercentage = 70, nSievePercentage = 10, nSieveSize = 1000000
GeneratePrimeTable() : prime table [1, 1000000] generated with 78498 primes
terminate called after throwing an instance of ‘std::runtime_error’
what(): no response from server

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application’s support team for more information.

C:\beeer\src>pause
Press any key to continue . . .[/code]

So, yea … bummer.

this guide is for 32bit only, kalup?
(as i can’t see any references to mingw64)

@ZorPrime: that could be the cause

You’re correct, I looked in my task manager and it’s a 32bit app. That explains a lot.

Now if I could figure out how to compile the x64 version … I suspect it’d be doing a whole lot better!

Anyone know what I should do differently to compile the x64 version … ?

[quote=“Zor Prime, post:2, topic:1110”]and I have to do this to get it to even try and compile:

[code]INCLUDEPATHS=
-I"$(CURDIR)"
-I"c:/deps/boost_1_54_0"
-I"C:/deps/db-4.8.30.NC/build_unix"
-I"c:/deps/openssl-1.0.1c/include"
-I"c:/deps/gmp/include"

LIBPATHS=
-L"$(CURDIR)/leveldb"
-L"c:/deps/boost_1_54_0/stage/lib"
-L"C:/deps/db-4.8.30.NC/build_unix"
-L"c:/deps/openssl-1.0.1c"

-L"c:/deps/gmp/lib"[/code]

Note the # -L"c:/deps/gmp/lib", it’ll otherwise say:[/quote]

I also had that cannot find -lgimp error.
No need to comment # -L"c:/deps/gmp/lib".
The problem is that gmp library incorrectly linked.

  1. at the top of bitcoin-qt.pro (along woth all the libraries and includes) add:

GMP_INCLUDE_PATH=C:/deps/gmp/include GMP_LIB_PATH=C:/deps/gmp/lib

  1. at the bottom, replace:

LIBS += -Wl,-Bdynamic -lgmp
with

INCLUDEPATH += $$GMP_INCLUDE_PATH LIBS += $$join(GMP_LIB_PATH,,-L,) -lgmp

I can compile the x86 versions all-day-long, what I need some help with is compiling a x64 version, which is unclear to me.

makefile.mingw64 results in a x86 version, not x64 unfortunately.

Thank you for the tutorial!
I’ve managed to compile the x86 version but I got stuck at the x64.
I can’t find how to install Boost with Mingw 64.
If somebody has managed to compile the x64 version please help!

Will theses steps work for compiling the GPU miner as well? I need an x86 version but I don’t want to waste hours if this won’t work for it…

Hello!
Today I have mail with Google Cloud’s advertising.
Their gives Virtual Machines with a little startup credit ($500).

Their languages are: Python, Java, Go and PHP.
Can You explain how-to start miner on their VM?