Bitcoin Forum
April 27, 2024, 05:23:52 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Building headless Crypto and Crypto-qt on Windows(MSYS2)  (Read 201 times)
DigitalCoinBRL (OP)
Member
**
Offline Offline

Activity: 308
Merit: 13

CEO/DEV - SperoCoin


View Profile WWW
October 26, 2020, 09:02:08 PM
Last edit: January 16, 2021, 07:18:54 PM by DigitalCoinBRL
Merited by ABCbits (1), NotATether (1)
 #1

This tutorial is based on the topic of our friend nitrogenetics, which is found at the link.

System used in the tutorial: Windows 10 x64 / build 19042.746 / version 20H2

System Preparation
01 - Install Msys2 Shell:
Download: https://www.msys2.org/

02 - Update Msys2
After downloading and installing the program, run the msys2.exe application and run the following commands:

Code:
pacman -Syu

As soon as the first update is performed, close and reopen msys2.exe. Run the commands:

Code:
pacman -Su
pacman -S git make
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain \
git subversion mercurial \
mingw-w64-i686-cmake mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-make mingw-w64-i686-make
pacman -S mingw-w64-x86_64-zlib mingw-w64-i868-zlib

Add the MinGW path to the system variables, being added to the PATH option of the operating system. In Windows 10 the path should look like the example below:

32BITS
Code:
C:\msys64\mingw32\bin

64BITS
Code:
C:\msys64\mingw64\bin

Download, extract and build the dependencies:

Create two dependency folders called deps_x86 and deps_x64 on disk C :.
All dependencies will be installed inside these folders.

01 - Download and installation - OPENSSL 1.1.1h:
Download the file below in the dependencies folder and open Msys2 MinGW 64-bit or Msys2 MinGW 32-bit according to the system choice for compilation

https://www.openssl.org/source/openssl-1.1.1h.tar.gz

Then enter the codes below in the command window that will open.

32BITS
Code:
cd /c/deps_x86/
tar xvfz openssl-1.1.1h.tar.gz
cd openssl-1.1.1h
./configure mingw
make

64BITS
Code:
cd /c/deps_x64/
tar xvfz openssl-1.1.1h.tar.gz
cd openssl-1.1.1h
./configure mingw64
make

02 - Download and installation - Berkeley DB:
Download the file below in the dependencies folder and open Msys2 MinGW 64-bit or Msys2 MinGW 32-bit according to the system choice for compilation

http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz

Then enter the codes below in the command window that will open.

32BITS
Code:
cd /c/deps_x86/
tar xvfz db-4.8.30.tar.gz
cd db-4.8.30/build_unix
../dist/configure --enable-mingw --enable-cxx --disable-shared --disable-replication
make

64BITS
Code:
cd /c/deps_x64/
tar xvfz db-4.8.30.tar.gz
cd db-4.8.30/build_unix
../dist/configure --enable-mingw --enable-cxx --disable-shared --disable-replication
make

03 - Download and install - 7-zip:
Download: https://www.7-zip.org/download.html

04 - Download and install - Boost 1.65:
Download and extract the folder in the dependencies directory.

https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.zip

Then open the Windows command prompt and enter the codes below.

32BITS
Code:
cd C:\deps_x86\boost_1_65_1\
bootstrap.bat gcc
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi runtime-link=static stage

64BITS
Code:
cd C:\deps_x64\boost_1_65_1\
bootstrap.bat gcc
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi runtime-link=static stage

05 - Download and installation - Miniupnpc:
Download and extract the folder in the dependencies directory.

http://miniupnp.free.fr/files/download.php?file=miniupnpc-2.1.tar.gz

After extracting the files, rename the miniupnpc-2.1 folder to miniupnpc.
Then open the Windows command prompt and enter the codes below.

32BITS
Code:
cd C:\deps_x86\miniupnpc
mingw32-make -f Makefile.mingw init upnpc-static

64BITS
Code:
cd C:\deps_x64\miniupnpc
mingw32-make -f Makefile.mingw init upnpc-static


06 - Download and installation - Protoc and Libprotobuf:
Download and extract the folder in the dependencies directory.

https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0/protobuf-all-3.7.0.zip

Extract the files using 7-zip.
Open Msys2 MinGW 64-bit. Then enter the codes below in the command window that will open.

32BITS
Code:
cd /c/deps_x86/
cd protobuf-3.7.1
./configure --disable-shared
make

64BITS
Code:
cd /c/deps_x64/
cd protobuf-3.7.1
./configure --disable-shared
make

07 - Download and install - Qrencode:
Download the file below in the dependencies folder and open Msys2 MinGW 64-bit or Msys2 MinGW 32-bit according to the system choice for compilation

http://download.sourceforge.net/libpng/libpng-1.6.36.tar.gz

Then enter the codes below in the command window that will open.

32BITS
Code:
cd /c/deps_x86/
tar xvfz libpng-1.6.36.tar.gz
cd libpng-1.6.36
./configure --disable-shared
make
cp .libs/libpng16.a .libs/libpng.a

64BITS
Code:
cd /c/deps_x64/
tar xvfz libpng-1.6.36.tar.gz
cd libpng-1.6.36
./configure --disable-shared
make
cp .libs/libpng16.a .libs/libpng.a

Download the file below in the dependencies folder and open Msys2 MinGW 64-bit or Msys2 MinGW 32-bit according to the system choice for compilation

http://fukuchi.org/works/qrencode/qrencode-4.0.2.tar.gz

Then enter the codes below in the command window that will open.

32BITS
Code:
cd /c/deps_x86/
tar xvfz qrencode-4.0.2.tar.gz
cd qrencode-4.0.2
LIBS="../libpng-1.6.36/.libs/libpng.a ../../msys64/mingw64/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.36" \
png_LIBS="-L../libpng-1.6.36/.libs" \
./configure --enable-static --disable-shared --without-tools
make

64BITS
Code:
cd /c/deps_x64/
tar xvfz qrencode-4.0.2.tar.gz
cd qrencode-4.0.2
LIBS="../libpng-1.6.36/.libs/libpng.a ../../msys64/mingw32/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.36" \
png_LIBS="-L../libpng-1.6.36/.libs" \
./configure --enable-static --disable-shared --without-tools
make


08 - Download and installation - Qt 5:
Download QT OpenSource.
https://download.qt.io/official_releases/qt/5.12/5.12.10/single/qt-everywhere-src-5.12.10.zip

Extract the file using 7-zip. Rename the qt-everywhere-src-5.12.10 folder to 5.12.10.
Create two folders called QT_x86 and QT_x64 on disk C :, copy folder 5.12.10 to the folders created earlier.
Then open the Windows command prompt and enter the codes below.

32BITS
Code:
cd C:\Qt_x86\5.12.10
configure.bat -release -opensource -confirm-license -static -make libs -no-sql-sqlite -no-opengl -nomake examples -no-icu -no-gif -no-libjpeg -no-freetype -no-angle -system-zlib -openssl -I C:\deps_x86\openssl-1.1.1h\include -L C:\deps_x86\openssl-1.1.1h

mingw32-make

64BITS
Code:
cd C:\Qt_x64\5.12.10
configure.bat -release -opensource -confirm-license -static -make libs -no-sql-sqlite -no-opengl -nomake examples -no-icu -no-gif -no-libjpeg -no-freetype -no-angle -system-zlib -openssl -I C:\deps_x64\openssl-1.1.1h\include -L C:\deps_x64\openssl-1.1.1h

mingw32-make


Note¹: Consider using -j with mingw32-make to speed up compilation. QuadCore -j4 or -j5 processors have had good results.
Note²: Dependency versions may vary depending on the currency being used.

1714238632
Hero Member
*
Offline Offline

Posts: 1714238632

View Profile Personal Message (Offline)

Ignore
1714238632
Reply with quote  #2

1714238632
Report to moderator
1714238632
Hero Member
*
Offline Offline

Posts: 1714238632

View Profile Personal Message (Offline)

Ignore
1714238632
Reply with quote  #2

1714238632
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714238632
Hero Member
*
Offline Offline

Posts: 1714238632

View Profile Personal Message (Offline)

Ignore
1714238632
Reply with quote  #2

1714238632
Report to moderator
DigitalCoinBRL (OP)
Member
**
Offline Offline

Activity: 308
Merit: 13

CEO/DEV - SperoCoin


View Profile WWW
January 14, 2021, 05:24:42 PM
 #2

Updated tutorial!

NotATether
Legendary
*
Online Online

Activity: 1582
Merit: 6688


bitcoincleanup.com / bitmixlist.org


View Profile WWW
January 16, 2021, 09:53:51 AM
Last edit: January 16, 2021, 12:12:48 PM by NotATether
 #3

I see that having download links to all the dependencies is useful in particular when trying to build the Berkeley DB part of Bitcoin Core yourself, because it's so ancient that newer versions of BDB are incompatible with anything bitcoin-related, at least from the projects I try odd to compile, and will generate linking errors during compilation.

So I thought it would be useful to have separate instructions for building BDB by itself on Linux.

Code:
pushd /tmp
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix. # see [1]
../dist/configure --prefix=/usr/local. # see [2]
make
make install
popd   # changes you back to wherever folder you were in before

[1] Yes, you absolutely have to build Berkeley DB in this folder, otherwise it will spit out an error like this:

Code:
checking if building in the top-level or dist directories... yes
configure: error: Berkeley DB should not be built in the top-level or "dist" directories. Change directory to the build_unix directory and run ../dist/configure from there.

[2] It installs it to /usr/local so that it does not conflict with any system-wise installation of Berkeley DB.

Now to compile stuff with it just pass -I/usr/local/include -L/usr/local/lib -ldb to gcc. And then you run your program like this:

Code:
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH program-name

Or

Code:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# many commands later...
program-name

The latter is useful to put in your .bash_profile or .bashrc so that it's automatically set for you at login.

Failing to set LD_LIBRARY_PATH will give you the following error when you start your program:

Code:
error while loading shared libraries: libdb-4.8.so: cannot open shared object file: No such file or directory

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DigitalCoinBRL (OP)
Member
**
Offline Offline

Activity: 308
Merit: 13

CEO/DEV - SperoCoin


View Profile WWW
January 16, 2021, 07:17:31 PM
 #4

I see that having download links to all the dependencies is useful in particular when trying to build the Berkeley DB part of Bitcoin Core yourself, because it's so ancient that newer versions of BDB are incompatible with anything bitcoin-related, at least from the projects I try odd to compile, and will generate linking errors during compilation.

So I thought it would be useful to have separate instructions for building BDB by itself on Linux.

Code:
pushd /tmp
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix. # see [1]
../dist/configure --prefix=/usr/local. # see [2]
make
make install
popd   # changes you back to wherever folder you were in before

[1] Yes, you absolutely have to build Berkeley DB in this folder, otherwise it will spit out an error like this:

Code:
checking if building in the top-level or dist directories... yes
configure: error: Berkeley DB should not be built in the top-level or "dist" directories. Change directory to the build_unix directory and run ../dist/configure from there.

[2] It installs it to /usr/local so that it does not conflict with any system-wise installation of Berkeley DB.

Now to compile stuff with it just pass -I/usr/local/include -L/usr/local/lib -ldb to gcc. And then you run your program like this:

Code:
LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH program-name

Or

Code:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# many commands later...
program-name

The latter is useful to put in your .bash_profile or .bashrc so that it's automatically set for you at login.

Failing to set LD_LIBRARY_PATH will give you the following error when you start your program:

Code:
error while loading shared libraries: libdb-4.8.so: cannot open shared object file: No such file or directory

Thank you very much for the feedback!
As you can see in the title, I tried to specify that it is for Windows systems and not separately for Bitcoin, but any other type of currency that follows the same compilation line of the tutorial provided by our friend nitrogenetics.

Note that I also informed that the dependencies can be different depending on the project you are looking to work on, a lot can change in different versions of projects. In any case, the dependencies and versions must be the same as those described in the project documentation you are looking to use.

Pages: [1]
  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!