Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cellard on March 11, 2019, 04:27:41 AM



Title: What is the best distro to compile windows binaries?
Post by: cellard on March 11, 2019, 04:27:41 AM
I want to compile the executable for windows on linux, it's a fork of Core of some altcoin, there's no way im installing altcoin stuff without compiling the source code. Which is the distro that will have all the libraries needed to build the binaries?

Will this work in the latest Ubuntu?

Code:
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.

then get the .git and:

Code:
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make


Title: Re: What is the best distro to compile windows binaries?
Post by: HeRetiK on March 11, 2019, 03:40:24 PM
Why not just run it (or compile it) on a virtual Windows machine?

I've never made use of it myself, but AFAIK Microsoft overs free time-limited images for virtual machine set ups. For example here's a bunch of Windows 7 images primarily used for IE testing, but they should support other basic Windows functionalities as well:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/


Title: Re: What is the best distro to compile windows binaries?
Post by: seoincorporation on March 11, 2019, 03:52:42 PM
I want to compile the executable for windows on linux, it's a fork of Core of some altcoin, there's no way im installing altcoin stuff without compiling the source code. Which is the distro that will have all the libraries needed to build the binaries?

Will this work in the latest Ubuntu?

Code:
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.

then get the .git and:

Code:
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make

The last time i did this was like 10 years ago.

I write code on C++ and then compile it as .exe, and the tool i used what the same you mention (Mingw), the code was something like:

Code:
 i586-mingw32msvc-g++ -o myApp.exe myApp.cpp

If you want to learn more about this topic you should google about cross compiling, i will leave a couple of sources for you  ;)

http://forums.codeblocks.org/index.php?topic=3343.0
https://stackoverflow.com/questions/2033997/how-to-compile-for-windows-on-linux-with-gcc-g


Title: Re: What is the best distro to compile windows binaries?
Post by: achow101 on March 11, 2019, 04:57:26 PM
Bitcoin Core provides fairly detailed step by step instructions for cross compiling for Windows using Ubuntu: https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux. It would probably be the easiest and least buggy for you to use Ubuntu and just follow those instructions.

The only dependency that is really required is MinGW. All other dependencies are built by the depends system.


Title: Re: What is the best distro to compile windows binaries?
Post by: cellard on March 12, 2019, 04:12:00 AM
Why not just run it (or compile it) on a virtual Windows machine?

I've never made use of it myself, but AFAIK Microsoft overs free time-limited images for virtual machine set ups. For example here's a bunch of Windows 7 images primarily used for IE testing, but they should support other basic Windows functionalities as well:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

I trust Linux live environment better than Windows VM. If your Windows machine was compromised, then the compiled code could be compromised. Why not minimize this risk by using a Live boot.

Bitcoin Core provides fairly detailed step by step instructions for cross compiling for Windows using Ubuntu: https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux. It would probably be the easiest and least buggy for you to use Ubuntu and just follow those instructions.

The only dependency that is really required is MinGW. All other dependencies are built by the depends system.

Thanks. I will try to download later "Ubuntu Bionic 18.04" specifically, not sure if its the latest, I guess so. I will boot from a live USB. Get the exe and save it somewhere.


Title: Re: What is the best distro to compile windows binaries?
Post by: DaCryptoRaccoon on March 14, 2019, 02:36:20 AM
This might be what your looking  working in debian

 ;)
Code:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git

Then choose:

-------------------------------------------------
Option A: Cross-compile Windows wallets (64 bit)
-------------------------------------------------

sudo apt-get install g++-mingw-w64-x86-64 mingw-w64-x86-64-dev

# Pick posix version for the following!

sudo update-alternatives --config x86_64-w64-mingw32-gcc
sudo update-alternatives --config x86_64-w64-mingw32-g++

cd depends

make -j 24 HOST=x86_64-w64-mingw32

# *** TIME FOR A REST HERE THIS TAKES SOME TIME ***

cd ..

./autogen.sh

CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/

make -j 24

Optional: strip the binaries to reduce size at this point if you're going to share them.

-------------------------------------------------
Option B: Compile native Linux wallets
-------------------------------------------------

cd depends

make -j 24

# *** ANOTHER PLEASE WAIT MOMENT OR TWO ***

cd ..

./autogen.sh

CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure --prefix=/

make -j 24

Optional: strip the binaries to reduce size at this point if you're going to share them.