Bitcoin Forum
November 14, 2024, 11:31:38 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 »  All
  Print  
Author Topic: [HOWTO] compile altcoin for windows on linux using mxe and mingw  (Read 49105 times)
main.h (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 1


View Profile
June 04, 2015, 02:45:26 PM
Last edit: December 28, 2016, 11:13:56 AM by main.h
 #1

Hello!
In this tutorial I show you how to cross compile altcoin-qt using mxe and mingw.
What is mxe? Well this is set of makefiles allowing you compile an cross environment with needed packages (mingw-w64, qt, boost, etc) without pain.

For example I will compile blackcoin-qt for 32-bit Windows on 64-bit Ubuntu 14.04 LTS, but this method should work with another altcoins.

Step 1.
Firstly we need install cross compile environment.

Install mxe dependencies:
Code:
sudo apt-get install p7zip-full autoconf automake autopoint bash bison bzip2 cmake flex gettext git g++ gperf intltool libffi-dev libtool libltdl-dev libssl-dev libxml-parser-perl make openssl patch perl pkg-config python ruby scons sed unzip wget xz-utils

For 64-bit Ubuntu also install:
Code:
sudo apt-get install g++-multilib libc6-dev-i386

Step 2.

Clone mxe github repo (if you just download zip archive from guthub, mxe may not work):
Code:
cd /mnt
git clone https://github.com/mxe/mxe.git

Our environment will be placed in /mnt/mxe

Step 3.
Now we need compile boost and qt5 for our environment (need a couple of hours for this).
If you compile something using mxe and move mxe directory to another place, then mxe will not work because all what you compile linked statically
Compiling boost will fail if memory of your PC less then 2GB. Making swap partition will fix this.

Compile boost:
Code:
cd /mnt/mxe
make MXE_TARGETS="i686-w64-mingw32.static" boost

Compile qt5:
Code:
make MXE_TARGETS="i686-w64-mingw32.static" qttools

If you need qt4 (for some altcoins):
Code:
make MXE_TARGETS="i686-w64-mingw32.static" qt

mxe automatically determine all dependencies and compile it.

Step 4.
Unfortunately mxe not support berkeley db and miniupnpc so we need compile them manually.

Compiling berkley db:
Download and unpack berkeley db:
Code:
cd /mnt
wget http://download.oracle.com/berkeley-db/db-5.3.28.tar.gz
tar zxvf db-5.3.28.tar.gz

Make bash script for compilation:
Code:
cd /mnt/db-5.3.28
touch compile-db.sh
chmod ugo+x compile-db.sh

Content of compile-db.sh:
Code:
#!/bin/bash
MXE_PATH=/mnt/mxe
sed -i "s/WinIoCtl.h/winioctl.h/g" src/dbinc/win_db.h
mkdir build_mxe
cd build_mxe

CC=$MXE_PATH/usr/bin/i686-w64-mingw32.static-gcc \
CXX=$MXE_PATH/usr/bin/i686-w64-mingw32.static-g++ \
../dist/configure \
--disable-replication \
--enable-mingw \
--enable-cxx \
--host x86 \
--prefix=$MXE_PATH/usr/i686-w64-mingw32.static

make

make install

Compile:
Code:
./compile-db.sh

Compiling miniupnpc:
Download and unpack miniupnpc:
Code:
cd /mnt
wget http://miniupnp.free.fr/files/miniupnpc-1.6.20120509.tar.gz
tar zxvf miniupnpc-1.6.20120509.tar.gz

Make bash script for compilation:
Code:
cd /mnt/miniupnpc-1.6.20120509
touch compile-m.sh
chmod ugo+x compile-m.sh

Content of compile-m.sh:
Code:
#!/bin/bash
MXE_PATH=/mnt/mxe

CC=$MXE_PATH/usr/bin/i686-w64-mingw32.static-gcc \
AR=$MXE_PATH/usr/bin/i686-w64-mingw32.static-ar \
CFLAGS="-DSTATICLIB -I$MXE_PATH/usr/i686-w64-mingw32.static/include" \
LDFLAGS="-L$MXE_PATH/usr/i686-w64-mingw32.static/lib" \
make libminiupnpc.a

mkdir $MXE_PATH/usr/i686-w64-mingw32.static/include/miniupnpc
cp *.h $MXE_PATH/usr/i686-w64-mingw32.static/include/miniupnpc
cp libminiupnpc.a $MXE_PATH/usr/i686-w64-mingw32.static/lib

Compile:
Code:
./compile-m.sh

Step 5.
Yay! Making our environment is done! Now we can compile blackcoin.

Add mxe bins to PATH:
Code:
export PATH=/mnt/mxe/usr/bin:$PATH

Download and unpack blackcoin sources:
Code:
cd /mnt
git clone https://github.com/rat4/blackcoin.git

Make bash script for compilation:
Code:
cd /mnt/blackcoin
touch compile-blk.sh
chmod ugo+x compile-blk.sh

Content of compile-blk.sh:
Code:
#!/bin/bash
MXE_INCLUDE_PATH=/mnt/mxe/usr/i686-w64-mingw32.static/include
MXE_LIB_PATH=/mnt/mxe/usr/i686-w64-mingw32.static/lib

i686-w64-mingw32.static-qmake-qt5 \
BOOST_LIB_SUFFIX=-mt \
BOOST_THREAD_LIB_SUFFIX=_win32-mt \
BOOST_INCLUDE_PATH=$MXE_INCLUDE_PATH/boost \
BOOST_LIB_PATH=$MXE_LIB_PATH \
OPENSSL_INCLUDE_PATH=$MXE_INCLUDE_PATH/openssl \
OPENSSL_LIB_PATH=$MXE_LIB_PATH \
BDB_INCLUDE_PATH=$MXE_INCLUDE_PATH \
BDB_LIB_PATH=$MXE_LIB_PATH \
MINIUPNPC_INCLUDE_PATH=$MXE_INCLUDE_PATH \
MINIUPNPC_LIB_PATH=$MXE_LIB_PATH \
QMAKE_LRELEASE=/mnt/mxe/usr/i686-w64-mingw32.static/qt5/bin/lrelease blackcoin-qt.pro

make -f Makefile.Release

Compile:
Code:
./compile-blk.sh

And that all.
Our blackcoin-qt.exe placed in /mnt/blackcoin/release
Hope this help someone
becool
Legendary
*
Offline Offline

Activity: 1442
Merit: 1016


View Profile
June 20, 2015, 04:45:53 PM
Last edit: June 20, 2015, 06:17:24 PM by becool
 #2


Compile boost:
Code:
cd /mnt/mxe
make MXE_TARGETS="i686-w64-mingw32.static" boost

if error message:
Missing requirement: libtool
than
Code:
sudo apt-get install libtool-bin


Step 3.
Now we need compile boost and qt5 for our environment (need a couple of hours for this).

less than one hour if i5+SSD

lulupon
Member
**
Offline Offline

Activity: 67
Merit: 10


View Profile
July 21, 2015, 10:41:17 AM
 #3

If you have levelDB issue (libleveldb.a / libmemenv.a), plz follow below instruction.

Code:
cd %coin_folder%/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a CC=/mnt/mxe/usr/bin/i686-w64-mingw32.static-gcc CXX=/mnt/mxe/usr/bin/i686-w64-mingw32.static-g++

BTC Address :
1ASUDTboPQsG9t2DE3Y29jnDSEgwybFc32
john75077
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile WWW
August 04, 2015, 01:02:29 PM
 #4

Morning,

I decided to give this a try since I'm new to the whole bitcoin / altcoin scene. This is the error I am getting when I try to compile, and I didnt see a Makefile.Release...

Code:
[build]     qtxlsxwriter         i686-w64-mingw32.static                        
[done]      qtxlsxwriter         i686-w64-mingw32.static                                    156204 KiB     0m57.310s
[no-build]  qt5                  i686-w64-mingw32.static
--------------------------------------------------------------------------------------------
./compile-blk.sh: line 6: i686-w64-mingw32.static-qmake-qt5: command not found
make: Makefile.Release: No such file or directory
make: *** No rule to make target `Makefile.Release'.  Stop.

Which step am I missing?

I am compiling this using Ubuntu 14.04 LTS x86_64
Fuzzbawls
Hero Member
*****
Offline Offline

Activity: 750
Merit: 500



View Profile
August 04, 2015, 07:07:48 PM
 #5

Morning,

I decided to give this a try since I'm new to the whole bitcoin / altcoin scene. This is the error I am getting when I try to compile, and I didnt see a Makefile.Release...

Code:
[build]     qtxlsxwriter         i686-w64-mingw32.static                        
[done]      qtxlsxwriter         i686-w64-mingw32.static                                    156204 KiB     0m57.310s
[no-build]  qt5                  i686-w64-mingw32.static
--------------------------------------------------------------------------------------------
./compile-blk.sh: line 6: i686-w64-mingw32.static-qmake-qt5: command not found
make: Makefile.Release: No such file or directory
make: *** No rule to make target `Makefile.Release'.  Stop.

Which step am I missing?

I am compiling this using Ubuntu 14.04 LTS x86_64

Verify that your PATH env var contains the correct location for mxe

Code:
export PATH=/mnt/mxe/usr/bin:$PATH
john75077
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile WWW
August 04, 2015, 11:06:25 PM
Last edit: August 04, 2015, 11:22:43 PM by john75077
 #6

Everything is compiling so far when I execute the script as root, if there is any other issues ill let you know. - It compiled with no issues! I don't have much for BTC if you leave your address ill send you something for the help.
sdmathis
Hero Member
*****
Offline Offline

Activity: 546
Merit: 500


AKA The Rubber Monkey


View Profile
August 06, 2015, 04:03:48 PM
 #7

Great tutorial. It works perfectly. Thank you very much.

I have one question. You stated that some altcoins need QT4 instead of QT5. Do I have to choose just one or the other, or can I install both? Will any problems occur if both are installed?

Thanks.

john75077
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile WWW
August 13, 2015, 04:02:48 PM
 #8

How do I use this to make the daemon for Ubuntu?
Fuzzbawls
Hero Member
*****
Offline Offline

Activity: 750
Merit: 500



View Profile
August 13, 2015, 09:24:17 PM
 #9

How do I use this to make the daemon for Ubuntu?

You don't. this thread is specifically about cross compiling wallets for windows, using linux as your compile OS.

Great tutorial. It works perfectly. Thank you very much.

I have one question. You stated that some altcoins need QT4 instead of QT5. Do I have to choose just one or the other, or can I install both? Will any problems occur if both are installed?

Thanks.

It is possible to have both qt4 and qt5 available for cross compiling at the same time. I personally have chosen to NOT build any qt4 wallet anymore and instead update the wallet's source to support a qt5 build. This, however is a time consuming task so it may not be worth it for you.
bitcreditscc
Hero Member
*****
Offline Offline

Activity: 602
Merit: 501



View Profile
August 16, 2015, 07:53:15 AM
 #10

How to mod this to compile Bitcoin?

CryptoVote
Full Member
***
Offline Offline

Activity: 229
Merit: 100



View Profile
August 28, 2015, 02:39:56 AM
Last edit: August 28, 2015, 03:59:37 AM by CryptoVote
 #11

Nice tutorial. Thanks!

There is a small mistake and think you should change this step:
Install mxe dependencies:
Code:
sudo apt-get install apt-get install autoconf automake autopoint bash bison bzip2 cmake flex gettext git g++ gperf intltool libffi-dev libtool libltdl-dev libssl-dev libxml-parser-perl make openssl patch perl pkg-config python ruby scons sed unzip wget xz-utils
To
Code:
sudo apt-get install autoconf automake autopoint bash bison bzip2 p7zip-full cmake flex gettext git g++ gperf intltool libffi-dev libtool libltdl-dev libssl-dev libxml-parser-perl make openssl patch perl pkg-config python ruby scons sed unzip wget xz-utils

The apt-get install is duplicated and it is missing 7-Zip.

BTCDDev
Sr. Member
****
Offline Offline

Activity: 255
Merit: 251


View Profile
August 28, 2015, 02:53:39 AM
 #12

Hi,

I developed a method for building BitcoinDark using mxe several months ago with help from fsb4000 and mezzovide.

You can see the automated build process here: https://github.com/jl777/btcd/blob/master/libjl777/make_win32.sh

Mezzovide in supernet slack even created a custom mxe package for building bdb 4.8: https://github.com/jl777/btcd/blob/master/libjl777/mxepatch/bdb48.mk

After you do this, export your path to mxe/usr/bin and make your coin:

https://github.com/jl777/btcd/blob/master/libjl777/Makefile.win

Quote
btcd: ../src/BitcoinDarkd-$(OS).exe; \
    cd ../src; $(MAKE) clean -f Makefile.win OS=$(OS); cd leveldb; $(MAKE) clean; cd ..; $(MAKE) -f Makefile.win OS=$(OS); strip BitcoinDarkd-$(OS).exe; cp BitcoinDarkd-$(OS).exe $(BINPATH)/$(OS)/BitcoinDarkd.exe

Matthew

BitcoinDark: RPHWc5CwP9YMMbvXQ4oXz5rQHb3pKkhaxc
Top Donations: juicybirds 420BTCD ensorcell 84BTCD Stuntruffle: 40BTCD
Top April Donations: juicybirds 420BTCD; ensorcell: 42BTCD
BTCDDev
Sr. Member
****
Offline Offline

Activity: 255
Merit: 251


View Profile
September 02, 2015, 02:42:38 PM
 #13

In fact, thanks to mezzovide, you no longer need to build bdb separately.

https://github.com/mxe/mxe/pull/791

BitcoinDark, making it easier to build on Windows


Matthew

BitcoinDark: RPHWc5CwP9YMMbvXQ4oXz5rQHb3pKkhaxc
Top Donations: juicybirds 420BTCD ensorcell 84BTCD Stuntruffle: 40BTCD
Top April Donations: juicybirds 420BTCD; ensorcell: 42BTCD
Bitr8er
Full Member
***
Offline Offline

Activity: 233
Merit: 100



View Profile
September 08, 2015, 06:44:10 AM
 #14


How would you code if you wanted to require a minimum version of a wallet to connect to the network?
such a only allow version 1.0.0.1 to connect
BTCDDev
Sr. Member
****
Offline Offline

Activity: 255
Merit: 251


View Profile
September 08, 2015, 02:11:21 PM
 #15


How would you code if you wanted to require a minimum version of a wallet to connect to the network?
such a only allow version 1.0.0.1 to connect


That's not really related to this topic.

Are you meaning this though?

https://github.com/laowais/bitcoindark/blob/master/src/version.h#L39

BitcoinDark: RPHWc5CwP9YMMbvXQ4oXz5rQHb3pKkhaxc
Top Donations: juicybirds 420BTCD ensorcell 84BTCD Stuntruffle: 40BTCD
Top April Donations: juicybirds 420BTCD; ensorcell: 42BTCD
temple
Hero Member
*****
Offline Offline

Activity: 1540
Merit: 550


Catalog Websites


View Profile
September 27, 2015, 06:01:26 AM
 #16

Code:
libtool: link: /mnt/mxe/usr/bin/i686-w64-mingw32.static-gcc -O3 -o db_archive db_archive.o util_sig.o  libdb-5.3.a
libdb-5.3.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [db_archive] Error 1

I encounter this problem. anyone know how to solve?


█████████████████████████
████████▀▀████▀▀█▀▀██████
█████▀████▄▄▄▄████████
███▀███▄███████████████
██▀█████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██▄███████████████▀▀▄▄███
███▄███▀████████▀███▄████
█████▄████▀▀▀▀████▄██████
████████▄▄████▄▄█████████
█████████████████████████
 
 BitList 
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
REAL-TIME DATA TRACKING
CURATED BY THE COMMUNITY

.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
 
  List #kycfree Websites   
redfish64
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
September 27, 2015, 06:50:45 AM
Last edit: September 27, 2015, 09:01:26 AM by redfish64
 #17

Code:
libtool: link: /mnt/mxe/usr/bin/i686-w64-mingw32.static-gcc -O3 -o db_archive db_archive.o util_sig.o  libdb-5.3.a
libdb-5.3.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [db_archive] Error 1

I encounter this problem. anyone know how to solve?



Just add the "RANLIB=...." as shown below:

Quote
#!/bin/bash
MXE_PATH=/mnt/mxe
sed -i "s/WinIoCtl.h/winioctl.h/g" src/dbinc/win_db.h
mkdir build_mxe
cd build_mxe


RANLIB=$MXE_PATH/usr/bin/i686-w64-mingw32.static-ranlib \
      CC=$MXE_PATH/usr/bin/i686-w64-mingw32.static-gcc \
      CXX=$MXE_PATH/usr/bin/i686-w64-mingw32.static-g++ \
      ../dist/configure \
      --disable-replication \
      --enable-mingw \
      --enable-cxx \
      --host x86 \
      --prefix=$MXE_PATH/usr/i686-w64-mingw32.static

make

make install
temple
Hero Member
*****
Offline Offline

Activity: 1540
Merit: 550


Catalog Websites


View Profile
September 27, 2015, 04:32:29 PM
 #18

Code:
libtool: link: /mnt/mxe/usr/bin/i686-w64-mingw32.static-gcc -O3 -o db_archive db_archive.o util_sig.o  libdb-5.3.a
libdb-5.3.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [db_archive] Error 1

I encounter this problem. anyone know how to solve?



Just add the "RANLIB=...." as shown below:

Quote
#!/bin/bash
MXE_PATH=/mnt/mxe
sed -i "s/WinIoCtl.h/winioctl.h/g" src/dbinc/win_db.h
mkdir build_mxe
cd build_mxe


RANLIB=$MXE_PATH/usr/bin/i686-w64-mingw32.static-ranlib \
      CC=$MXE_PATH/usr/bin/i686-w64-mingw32.static-gcc \
      CXX=$MXE_PATH/usr/bin/i686-w64-mingw32.static-g++ \
      ../dist/configure \
      --disable-replication \
      --enable-mingw \
      --enable-cxx \
      --host x86 \
      --prefix=$MXE_PATH/usr/i686-w64-mingw32.static

make

make install


Thanks man, you save my life  Wink

█████████████████████████
████████▀▀████▀▀█▀▀██████
█████▀████▄▄▄▄████████
███▀███▄███████████████
██▀█████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██▄███████████████▀▀▄▄███
███▄███▀████████▀███▄████
█████▄████▀▀▀▀████▄██████
████████▄▄████▄▄█████████
█████████████████████████
 
 BitList 
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
REAL-TIME DATA TRACKING
CURATED BY THE COMMUNITY

.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
 
  List #kycfree Websites   
main.h (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 1


View Profile
October 09, 2015, 09:56:37 AM
Last edit: December 28, 2016, 11:13:01 AM by main.h
 #19

The apt-get install is duplicated and it is missing 7-Zip.
Fixed. Thank you  Wink
altcoinhosting
Hero Member
*****
Offline Offline

Activity: 896
Merit: 1006


View Profile
October 09, 2015, 10:01:49 AM
 #20

Thanks, this tutorial looks really well-documented. Because i think it's really intresting to compile your own wallets, i'm going to replicate this scenario this weekend to see if everything works  Grin

Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!