Skip to content

Instantly share code, notes, and snippets.

@suryapratap1
Last active November 29, 2018 09:47
Show Gist options
  • Save suryapratap1/7f60893eec20ab9c3c425b24d0cbd0e4 to your computer and use it in GitHub Desktop.
Save suryapratap1/7f60893eec20ab9c3c425b24d0cbd0e4 to your computer and use it in GitHub Desktop.
Comiple QT wallet on linux for windows
This method should be suitable for any Unix system: Linux, FreeBSD, MacOS X
This guide was written on Linux Mint 17.1 (http://linuxmint.com/) and was tested on Ubuntu 14.04 (https://www.ubuntu.com/)
1) Preparing the system for cross-compilation.
sudo apt-get install git bison cmake flex g++ gperf ruby scons libghc-zlib-dev libghc-zlib-bindings-dev
2) Install MXE and dependencies
cd / home / <your name> /
git clone https://github.com/mxe/mxe.git
sudo apt-get install autoconf automake autopoint libtool intltool libtoolize p7zip-full libgtk2.0-dev
2.1) gcc
cd / home / <your name> / mxe
make gcc zlib libpng
Verifying that the gcc installation was successful:
The file i686-w64-mingw32.static-gcc and i686-w64-mingw32.static-g ++ should appear in the folder / home / <your name> / mxe / usr / bin
And when you run / home / <your name> /mxe/usr/bin/i686-w64-mingw32.static-gcc -v should be issued
......
Thread model: win32
gcc version 5.4.0 (GCC)
In the folder / home / <your name> /mxe/usr/i686-w64-mingw32.static/lib there should be files:
libz.a
libpng.a
2.2) Openssl
cd / home / <your name> / mxe
make openssl
Verifying that the installation of Openssl was successful:
Two files should appear in the folder / home / <your name> /mxe/usr/i686-w64-mingw32.static/lib
-libssl.a
-libcrypto.a
The folder openssl should appear in the mxe / usr / i686-w64-mingw32.static / include folder
2.3) Boost
cd / home / <your name> / mxe
make boost
Verifying that the Boost installation was successful:
In the / home / <your name> /mxe/usr/i686-w64-mingw32.static/lib files should appear:
-libboost_miblib_mt.a (libboost_atomic-mt.a and other similar files)
-libboost_mt-daemonlib libraries (libboost_atomic-mt-da and other similar files) - no !!!!!!!!!!!!
A folder should appear in the folder / home / <your name> /mxe/usr/i686-w64-mingw32.static/include
2.4) Berkeley DB
-Download http://download.oracle.com/berkeley-db/db-6.0.20.tar.gz
-Unpack to your home folder
-Open the file / home / <your name> /db-6.0.20/src/dbinc/win_db.h
- Change
#include <WinIoCtl.h>
on
#include <winioctl.h>
-Save file
-Open terminal:
cd / home / <your name> /db-6.0.20/dist
chmod +x configure
cd
cd / home / <your name> /db-6.0.20/build_unix
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
../dist/configure --host=i686-w64-mingw32.static --enable-mingw --enable-cxx --disable-shared --disable-replication
make
Verifying that the Berkeley DB installation was successful:
Files should appear in the folder / home / <your name> /db-6.0.20/build_unix:
libdb.a
libdb_cxx.a
2.5) qrencode
-Download http://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz
-Unpack to your home folder
-Open terminal:
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> /qrencode-3.4.4
chmod +x configure
./configure --host=i686-w64-mingw32.static --enable-static --disable-shared --without-tools
make
Verifying that qrencode was successfully assembled:
in the folder / home / <your name> /qrencode-3.4.4/.libs there should be a file:
libqrencode.a
2.6 Qt 5 и Qt 4
Qt 4
-Open terminal:
cd / home / <your name> / mxe
make qt
Verifying that Qt4 is set up correctly:
-Open terminal:
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
i686-w64-mingw32.static-qmake-qt4 -v
-Must appear in response
QMake version 2.01a
Using Qt version 4.8.7 in /home/<ваше имя>/mxe/usr/i686-w64-mingw32.static/qt/lib
Qt 5
-Open terminal:
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / mxe
make qtbase qttools qttranslations
Verifying that Qt5 is set up correctly:
-Open terminal:
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
i686-w64-mingw32.static-qmake-qt5 -v
-Must appear in response
QMake version 3.1
Using Qt version 5.8.0 in /home/<ваше имя>/mxe/usr/i686-w64-mingw32.static/qt5/lib
3. Compile
3.1 Download the source
-Go to your home folder
-Open terminal:
git clone https://github.com/42-coin/42.git
3.2 We collect 42d
-Open the makefile.mingw file in a text editor (for example, Pluma, gedit)
- Replace CC = gcc on
CC=$(CROSS)gcc
CXX=$(CROSS)g++
-Add the line USE_ASM: = 1
-Change the current INCLUDEPATHS, LIBPATHS, LIBS with:
BOOST_SUFFIX?=-mt
BOOST_THREAD_LIB_SUFFIX?=_win32-mt
INCLUDEPATHS= \
-I"$(CURDIR)" \
-I"/home/<ваше имя>/db-6.0.20/build_unix" \
LIBPATHS= \
-L"$(CURDIR)/leveldb" \
-L"/home/<ваше имя>/db-6.0.20/build_unix" \
LIBS= \
-l leveldb \
-l memenv \
-l boost_system$(BOOST_SUFFIX) \
-l boost_filesystem$(BOOST_SUFFIX) \
-l boost_program_options$(BOOST_SUFFIX) \
-l boost_thread$(BOOST_THREAD_LIB_SUFFIX) \
-l boost_chrono$(BOOST_SUFFIX) \
-l db_cxx \
-l ssl \
-l crypto \
-l z \
-l pthread
-Change in the last lines of the makefile.mingw
g++ -c $(CFLAGS) -o $@ $<
on
$(CXX) -c $(CFLAGS) -o $@ $<
g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
on
$(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
-If you want to use LevelDB as the base of blocks then change:
USE_LEVELDB:=0
on
USE_LEVELDB:=1
(above USE_IPV6: = 1)
Open the file / home / <your name> / 42 / src / leveldb / Makefile
Insert below the line CXXFLAGS + = -I. -I./include $ (PLATFORM_CXXFLAGS) $ (OPT) the following lines:
CC=$(CROSS)gcc
CXX=$(CROSS)g++
Save the file
Go back to the file makefile.mingw, change
cd leveldb;TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a; cd ..
on
cd leveldb; TARGET_OS=NATIVE_WINDOWS make CROSS=i686-w64-mingw32.static- libleveldb.a libmemenv.a; cd ..
If you want to use BerkeleyDB as the base of blocks, simply delete the line USE_LEVELDB: = 1
Edit
clean:
-del /Q 42d.exe
-del /Q obj\*
-del /Q crypto\scrypt\asm\obj\*
on
clean:
-rm 42d.exe
-rm obj/*
-rm crypto/scrypt/asm/obj/*
-Save the modified makefile.mingw file
-Open terminal:
cd / home / <your name> / 42 / src
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
make -jn CROSS = i686-w64-mingw32.static- -f makefile.mingw (instead of n number of cores of your processor that you want to allocate for the assembly)
strip 42d.exe
If everything is done correctly, the 42d.exe file will be located in the / home / <your name> / 42 / src folder.
3.3 Collapsible 42 QT
Warning: If you want to build 42 Qt with LevelDB, but missed a step with the build 42d.exe, then
-Change the Makefile in the leveldb folder as in paragraph 3.2.
-Open terminal:
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / 42 / src / leveldb
TARGET_OS=NATIVE_WINDOWS make CROSS=i686-w64-mingw32.static- libleveldb.a libmemenv.a
-Open the file / home / <your name> /42/42-qt.pro in a text editor (for example, Pluma, gedit)
-Below
# Dependency library locations can be customized with:
# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively
replace the prescribed dependency paths with
BOOST_LIB_SUFFIX=-mt
BOOST_THREAD_LIB_SUFFIX=_win32-mt
BDB_INCLUDE_PATH=/home/<ваше имя>/db-6.0.20/build_unix
BDB_LIB_PATH = / home / <your name> /db-6.0.20/build_unix
QRENCODE_INCLUDE_PATH=/home/<ваше имя>/qrencode-3.4.4
QRENCODE_LIB_PATH=/home/<ваше имя>/qrencode-3.4.4/.libs
Just change (if not yet changed)
LIBS += -lshlwapi
genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
on
LIBS += -lshlwapi
#genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
If there is no such line CONFIG + = static in the file, then add it.
Edit
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
on
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static
Edit
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
on
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
-Save the modified file 42-qt.pro
-Open the terminal and execute the following commands:
Qt4 + LevelDB Transaction Index
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / 42
i686-w64-mingw32.static-qmake-qt4 "USE_IPV6=1" "USE_LEVELDB=1" "USE_ASM=1" 42-qt.pro
make -jn -f Makefile.Release (instead of n the number of cores of your processor that you want to allocate for the assembly)
Qt4 + BDB Transaction Index
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / 42
i686-w64-mingw32.static-qmake-qt4 "USE_IPV6=1" "USE_ASM=1" 42-qt.pro
make -jn -f Makefile.Release (instead of n the number of cores of your processor that you want to allocate for the assembly)
Qt5 + LevelDB Transaction Index
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / 42
i686-w64-mingw32.static-qmake-qt5 "USE_IPV6=1" "USE_LEVELDB=1" "USE_ASM=1" 42-qt.pro
make -jn -f Makefile.Release (instead of n the number of cores of your processor that you want to allocate for the assembly)
Qt5 + BDB Transaction Index
export PATH = / home / <your name> / mxe / usr / bin: $ PATH
cd / home / <your name> / 42
i686-w64-mingw32.static-qmake-qt5 "USE_IPV6=1" "USE_ASM=1" 42-qt.pro
make -jn -f Makefile.Release (instead of n the number of cores of your processor that you want to allocate for the assembly)
If everything is done correctly, then the 42-qt.exe file will be located in the / home / <your name> / 42 / release folder.
If you want to reduce the size of binary files, then
1) Go to the site http://upx.sourceforge.net/#downloadupx
2) Download the program in accordance with your system
3) Unzip the program to the folder with 42 binary files.
4) Enter in the terminal
./upx -9 42d.exe
then
./upx -9 42-qt.exe
And your 42d and 42-qt will be less than ~ 3 times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment