Tuesday, January 25, 2022

How to install vs code-server in Windows WSL2 and setup firewall rules to access from other LAN machines

(1) Start Ubuntu 20.04 of WSL2 and install code-server
curl -fsSL https://code-server.dev/install.sh | sh

(2) Modify bind IP address port settings and password of the code-server
Get Ubuntu IP address
ifconfig eth0 | grep 'inet '
Edit bind address and password in
~/.config/code-server/config.yaml

(3) start code-server in Ubuntu
code-server

(4) Modify firewall rule and add forward port in Windows using PowerShell with Admin Right. Create the following file vscode_server_port_wsl2.ps1 and run in PowerShell with Admin Right
.\vscode_server_port_wsl2.ps1
vscode_server_port_wsl2.ps1    Select all
# Get network information $network_information = bash.exe -c "ifconfig eth0 | grep 'inet '"; # Define ip address pattern $ip_address_pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"; # Get ip address $ip_address = $network_information -match $ip_address_pattern # Proceed if ip address is found if ($ip_address) { # Get remote address $remote_address = $matches[0]; } # Define rule name $rule_name = "VS Code Server (WSL2)"; # Define port for the VS Code Server - default is 8080 $port = 8080; # Check if rule exists $rule_exists = Get-NetFirewallRule -DisplayName $rule_name 2> $null; # Proceed if rule doesn't exists if (-Not $rule_exists) { # Add new inbound rule New-NetFirewallRule -DisplayName $rule_name -Direction Inbound -LocalPort $port -Protocol TCP -Action Allow } # Define listen address $listen_address = "0.0.0.0"; # Update ip address iex "netsh interface portproxy delete v4tov4 listenport = $port listenaddress = $listen_address"; iex "netsh interface portproxy add v4tov4 listenport = $port listenaddress = $listen_address connectport = $port connectaddress = $remote_address";

Do this in powershell with admin right.

Set-ExecutionPolicy Unrestricted -Force





(5) Test access of code-server from other machine in the LAN
Use browser to access this address and enter password as in
http://<IP address of your windows machine>:8080/

(6) Test access of code-server from VPN connection from Internet.
First use OpenVPN to connect to your home/office network
Then use browser to access
http://<IP address of your windows machine>:8080/

(7) If you have installed docker for Windows, this command will help you to install and run code-server in docker.
command prompt shell    Select all
# Testing on local host machine docker run --name code-server -p 127.0.0.1:8080:8080 -v "$HOME/.config:/home/coder/.config" -v "$HOME/:/home/coder/project" -e "USER=$env:UserName" -e "DOCKER_USER=$env:UserName" codercom/code-server:latest #or publish to the host machine IP address with port no 8081, to allow access from other LAN machines docker run --name code-server -p 8081:8080 -v "$HOME/.config:/home/coder/.config" -v "$HOME/:/home/coder/project" -e "USER=$env:UserName" -e "DOCKER_USER=$env:UserName" codercom/code-server:latest # stop container docker stop code-server # start container docker start code-server
run this command to get the password in config.yaml and then edit it of wanted.
docker exec -it code-server cat .config/code-server/config.yaml
or
type $HOME\.config\code-server\config.yaml
. . .

Thursday, January 13, 2022

Decompile and Recompile an Android APK using apktool

You need these tools to do the jobs

Android Studio (with build tools such as keytool, jarsigner)
apktool download from https://bitbucket.org/iBotPeaches/apktool/downloads/ and extract and rename to apktool.jar
apktool wrapper script https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/windows/apktool.bat
Java SE 8 JDK download from https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html
dex2jar download from https://sourceforge.net/projects/dex2jar/
JD_GUI download from http://jd.benow.ca/
smalidea download from https://github.com/JesusFreke/smalidea
Online Decompiler for apk https://appscms.com/apk-decompiler
jadx download from https://github.com/skylot/jadx/releases

apktool — tool for reverse engineering Android apk files. In this case we are using to extract files from apk and rebuild.
keytool — Java tool for creating keys/certs, that comes with the Java SE JDK.
jarsigner Java tool for signing JAR/APK files, that comes with the Java SE JDK.
zipalign — archive alignment tool, that comes with the Android SDK.
JD-GUI — To view java code
dex2jar — Converts Android dex files to class/jar files.
smalidea is a smali language plugin for AS and to edit the file in Android Studio
jadx — convert single smali file to java code to test the modification of smali

For smali syntax, please refer to this doc
https://programmer.help/blogs/smali-introduction-manual.html
or http://source.android.com/devices/tech/dalvik/dalvik-bytecode.html

Instructions:
First, Take any apk file and unpack(decompile) it. This will create an “application” directory with assets, resources, compiled code, etc.
# To decompile an apk
apktool d -r -s my_application.apk
or
apktool d my_application.apk

Then, you can use Android Studio to open the smali file and edit it. Use APKRepacker to test the single smali file conversion.

# To recompile(build) the apk
apktool b -f -d my_application -o my_application2.apk

After recompiling (building) the apk the new apk (my_application2.apk) will be generated in directory.

The APK must be signed before you run on your device. If you want an official key from google play signing key, you should register with https://play.google.com/console/u/0/signup first and pay $25 registration key
Before signing an apk, create a self-signing key if you don't have an existing one from google play. If prompted for a password, create your own password.
These tools are installed withn JDK e.g. in "c:\Program Files\Java\jdk1.8.0_301\bin\". Add this to the environment PATH.

macOS binary are here /Applications/Android Studio.app/Contents/jre/Contents/Home/bin

# To generate a key. And remember the store password
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

# if want to generate SHA256withRSA keystore (in order to get rid of the warning of security when signing with SHA1), use this command
keytool -genkey -v -keystore my-release-key256.keystore -alias mykey256 -sigalg SHA256withRSA -keyalg RSA -keysize 2048 -validity 10000 -deststoretype pkcs12

Now sign the APK with the key:
# Sign the apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application2.apk alias_name

# if Sign with SHA256withRSA (in order to get rid of the warning of security when signing with SHA1)
jarsigner -verbose -sigalg SHA256withRSA -keystore my-release-key256.keystore my_application2.apk mykey256

# Verify apk
jarsigner -verify -verbose -certs -keystore my-release-key.keystore my_application2.apk

# Verify apk with SHA256withRSA
jarsigner -verify -verbose -certs -keystore my-release-key256.keystore my_application2.apk

# Finally, the apk must be aligned for optimal loading:
zipalign is installed with Android SDK e.g. in c:\Users\User\AppData\Local\Android\Sdk\build-tools\28.0.3\zipalign.exe Add this to the environment PATH.
zipalign -v 4 my_application2.apk my_application2-aligned.apk
you have a my_application2-aligned.apk file, which you can install onto your device.


Other useful tools using command prompt under Windows
# Command Prompt to list android virtual devices %USERPROFILE%\AppData\Local\Android\Sdk\emulator\emulator -list-avds
# PowerShell command to list android virtual devices & $env:UserProfile\AppData\Local\Android\Sdk\emulator\emulator -list-avds
# Command Prompt to list android virtual device in background
start /b %USERPROFILE%\AppData\Local\Android\Sdk\emulator\emulator -avd Pixel_3a_API_30_x86 -netdelay none -netspeed full
# Command Prompt to show running emulator devices
%USERPROFILE%\AppData\Local\Android\Sdk\platform-tools\adb devices
# Command Prompt to attach to running emulator device shell
%USERPROFILE%\AppData\Local\Android\Sdk\platform-tools\adb -s emulator-5554 shell
# Command Prompt to install apk to running emulator device
%USERPROFILE%\AppData\Local\Android\Sdk\platform-tools\adb -s emulator-5554 install %USERPROFILE%\Downloads\my_application2-aligned.apk
export ANDROID_HOME="%USERPROFILE%\AppData\Local\Android\Sdk"




Other useful tools using Terminal under macOS
# macOS Terminal to list android virtual devices $HOME/Library/Android/sdk/emulator/emulator -list-avds
# macOS Terminal to show running emulator devices
$HOME/Library/Android/sdk/platform-tools/adb devices
# macOS Terminal to attach to running emulator device shell
$HOME/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell
# macOS Terminal to install apk to running emulator device
$HOME/Library/Android/sdk/platform-tools/adb -s emulator-5554 install ~/Downloads/my_application2-aligned.apk
export ANDROID_HOME="$HOME/Library/Android/sdk" export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home" export PATH=$ANDROID_HOME/build-tools/30.0.3:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:$PATH


Setup sdk and decompile tools in WSL2 Ubuntu 20.04    Select all
#!/bin/bash sudo apt install -y libarchive-tools export ANDROID_SDK_TOOLS_VERSION=6858069 export ANDROID_SDK_TOOLS_CHECKSUM=87f6dcf41d4e642e37ba03cb2e387a542aa0bd73cb689a9e7152aad40a6e7a08 export ANDROID_HOME="/opt/android-sdk-linux" export ANDROID_SDK_ROOT="/opt/android-sdk-linux" export ANDROID_DECOMPILE_TOOLS="$ANDROID_HOME/Decompile" curl -s https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip > ./tools.zip && echo "$ANDROID_SDK_TOOLS_CHECKSUM ./tools.zip" | sha256sum -c && sudo mkdir -p $ANDROID_HOME && sudo chown $(id -u):$(id -g) $ANDROID_HOME && unzip -qq ./tools.zip -d $ANDROID_HOME && rm -v ./tools.zip sudo mkdir -p $ANDROID_HOME/licenses/ && sudo chown $(id -u):$(id -g) $ANDROID_HOME/licenses && echo "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_HOME/licenses/android-sdk-license && echo "84831b9409646a918e30573bab4c9c91346d8abd\n504667f4c0de7af1a06de9f4b1727b84351f2910" > $ANDROID_HOME/licenses/android-sdk-preview-license --licenses && yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses --sdk_root=${ANDROID_SDK_ROOT} curl -OL https://raw.githubusercontent.com/MobileDevOps/android-sdk-image/master/packages.txt $ANDROID_HOME/cmdline-tools/bin/sdkmanager --update --sdk_root=${ANDROID_SDK_ROOT} && while read -r pkg; do PKGS="${PKGS}${pkg} "; done < $HOME/packages.txt && $ANDROID_HOME/cmdline-tools/bin/sdkmanager $PKGS > /dev/null --sdk_root=${ANDROID_SDK_ROOT} curl -OL https://nchc.dl.sourceforge.net/project/dex2jar/dex2jar-2.0.zip && unzip dex2jar-2.0.zip -d $ANDROID_HOME/Decompile && chmod +x $ANDROID_HOME/Decompile/dex2jar-2.0/*.sh && rm -v dex2jar-2.0.zip mkdir -p $ANDROID_DECOMPILE_TOOLS/apktool && pushd $ANDROID_DECOMPILE_TOOLS/apktool && curl -OL https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.6.0.jar && ln -s apktool_2.6.0.jar apktool.jar && curl -OL https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool && chmod +x apktool && popd curl -OL https://github.com/skylot/jadx/releases/download/v1.3.3/jadx-1.3.3.zip && unzip jadx-1.3.3.zip -d $ANDROID_DECOMPILE_TOOLS/jadx && rm -v jadx-1.3.3.zip mkdir -p $ANDROID_DECOMPILE_TOOLS/java2smali && curl -OL https://github.com/izgzhen/java2smali/releases/download/1.1/dist.zip && bsdtar xvf dist.zip --strip-components=1 -C $ANDROID_DECOMPILE_TOOLS/java2smali/ && rm -v dist.zip mkdir -p $ANDROID_DECOMPILE_TOOLS/java2smali && pushd $ANDROID_HOME/Decompile/java2smali && curl -OL https://github.com/JesusFreke/smali/releases/download/v2.0b6/smali-2.0b6.jar && curl -OL https://github.com/JesusFreke/smali/releases/download/v2.0b6/baksmali-2.0b6.jar && curl -OL https://raw.githubusercontent.com/JesusFreke/smali/master/scripts/smali && curl -OL https://raw.githubusercontent.com/JesusFreke/smali/master/scripts/baksmali && popd pushd $ANDROID_DECOMPILE_TOOLS/java2smali && ln -s baksmali-2.0b6.jar baksmali.jar && ln -s smali-2.0b6.jar smali.jar && chmod +x baksmali && chmod +x smali && popd # Then append these lines to ~/.profile export ANDROID_HOME="/opt/android-sdk-linux" export ANDROID_SDK_ROOT=$ANDROID_HOME export ANDROID_DECOMPILE_TOOLS=="$ANDROID_HOME/Decompile" export PATH=$ANDROID_HOME/cmdline-tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/30.0.3:$ANDROID_DECOMPILE_TOOLS/jadx/bin:$ANDROID_DECOMPILE_TOOLS/java2smali:$ANDROID_DECOMPILE_TOOLS/apktool:$ANDROID_DECOMPILE_TOOLS/dex2jar-2.0:$PATH



Friday, November 12, 2021

Termux pkg update error on Android devices

If you have pkg update error on your old installation of Android devices

pkg install termux-tools
termux-change-repo

Tuesday, July 13, 2021

Personal Installation Guide for new Chromebook

(1) For new chromebook, there is free Google One 100GB and DropBox 100GB both for 1 year. See here. https://www.google.com/chromebook/perks/

(2) To enable google drive on Files app of Chrome OS, Bottom right clock -> Settings Icon -> Advanced -> Files -> Disconnect Google Drive account set to off.

(3) To enable DropBox on Files app of Chrome OS, Install DropBox app from Android Play Store and login dropbox.

(4) To enable smb share on Files app of Chrome OS, Open Files App and select the 3 dots menu on top right and Choose "Service" and then "SMB File Share".

(5) To enable OneDrive (readonly) on Files app of Chrome OS, Install OneDrive App from Google Play Store.

(5.1) How to share files or Google Drive with Linux apps on Chrome OS
    Select all
(a) Open the My Files app. (b) From within that app, locate the directory housing the documents you want accessible by the installed Linux apps. (c) Right-click the folder in question and then select Share With Linux. The sharing happens immediately. (d) Google Drive is in /mnt/chromeos/GoogleDrive/MyDrive/ (e) MyFiles is in /mnt/chromeos/MyFiles/




(6) If you cannot install Chrome OS Linux Beta Crostini now, install Termux App as a temporary solution, Download the apk file from here https://f-droid.org/en/packages/com.termux/ (Google Play Version was outdated).

(7) How to install Linux Web Development Environment on Chrome OS, see here https://www.youtube.com/watch?v=3CWUAisN-vo

shellscript.sh    Select all
# nodejs dependencies sudo apt install gnupg2 # install nodejs v14 and npm v6 curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - sudo apt-get install -y nodejs # try it out! Sweep for mines sudo apt install libnss3 git clone https://github.com/GoogleChromeLabs/proxx.git cd proxx npm install npm run build npm run serve # Install React npm install create-react-app # Create a React app npx create-react-app hello-world-react cd hello-world-react npm start # Install Angular npm install @angular/cli # Create an Angular app ng new my-angular-project cd my-angular-project ng serve # Docker Dependencies sudo apt install ca-certificates software-properties-common # Docker repository curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" # Install Docker-ce sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io # Install docker client only and connect to docker desktop of windows machine cd $HOME wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz tar xzvf docker-20.10.7.tgz ./docker/docker -H tcp://10.0.1.78:2375 images # Or simply add the corresponding variables to ~/.bashrc export DOCKER_HOST=tcp://192.168.1.78:2375 export PATH=$PATH:~/docker # # To detach the docker tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q + Ctrl-c # # for docker desktop on mac, see this solution to open tcp port https://stackoverflow.com/questions/39411126/access-docker-daemon-remote-api-on-docker-for-mac # on Mac machine brew install socat socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock &




(8) System requirement for Android Studio for Chrome OS is 8GB RAM and Intel i5 CPU or above.

(9) Flatpak applications can be installed on Chrome OS with the Crostini Linux compatibility layer. See here https://flatpak.org/setup/Chrome%20OS/

(10) Popular shortcuts https://support.google.com/chromebook/answer/183101?hl=en

(11) How to access onedrive in linux partition

shellscript.sh    Select all
# download latest deb package from https://launchpad.net/~jstaf/+archive/ubuntu/onedriver/+packages wget https://launchpad.net/~jstaf/+archive/ubuntu/onedriver/+files/onedriver_0.11.1-1_amd64.deb # install the deb package in linux sudo apt install ./onedriver_0.11.1-1_amd64.deb # reference from https://github.com/jstaf/onedriver # create mount point mkdir -p ~/onedrive # determine the service name export SERVICE_NAME=$(systemd-escape --template onedriver@.service --path ~/onedrive) # mount onedrive systemctl --user daemon-reload systemctl --user start $SERVICE_NAME # automatically mount onedrive when you login systemctl --user enable $SERVICE_NAME # query the status of onedriver systemctl --user status $SERVICE_NAME # check onedriver's logs for the current day journalctl --user -u $SERVICE_NAME --since today




P.S. if you cannot install Chrome OS Linux Beta Crostini, please refer to the reason in this article https://chromeunboxed.com/google-pauses-chrome-os-update-breaks-linux-container/



Saturday, July 3, 2021

How to install Windows 11 WSL2 GUI App

(1) If you have unspported hardware, please follow this guide to install Dev Channel Preview of Windows 11 -> update-any-pc-to-windows11

(2) After installed Windows 11 Preview, Start Windows Terminal (install from Microsoft Store) in Administrative Role. The following commands are entered using Windows Terminal with elevated admin rights.

(3) wslconfig /u ubuntu # if wsl already installed previously in Windows 10 and want to remove old ubuntu distro

(4.1) wsl --update # if wsl already installed previously in Windows 10 and needs update to WSLg

(4.2) wsl --shutdown # wsl needs to be restarted after update

(5) wsl --install -d Ubuntu # this will install WSLg on Windows 11 and the new Ubuntu 20.04 instance

(6) sudo apt install audacity # this will install audacity linux gui app for ubuntu

(7) Use Windows search function to search for Audacity (Ubuntu) App to start the linux GUI App under Windows 11.

(8) You can even install and run Chrome, Edge, or Teams under Ubuntu on Windows 11 with WSLg.

(9) To install flatpak for GUI App

Shellscript   Select all
sudo apt install flatpak # add repo flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo # search app and install flatpak search gimp flatpak install flathub org.gimp.GIMP


Tuesday, June 8, 2021

Hello swift async and await for Swift 5.5

(1) This is to test the new async and await feature for Swift 5.5 dev on Linux. First Download and install packages in Ubuntu 20.04.
Shell script for setup Swift 5.5   Select all
sudo apt-get install -y binutils git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata zlib1g-dev cd ${HOME} wget https://swift.org/builds/swift-5.5-branch/ubuntu2004/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a-ubuntu20.04.tar.gz tar xzvf swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a-ubuntu20.04.tar.gz export PATH=${HOME}/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a-ubuntu20.04/usr/bin:$PATH


(2) Create swift package for executable
Shell script testing async and await   Select all
cd ${HOME} mkdir -p ${HOME}/AsyncSwift cd ${HOME}/AsyncSwift swift package init --type executable


(3) Amend ${HOME}/AsyncSwift/Package.swift to have swift setting flags
Package.swift   Select all
// swift-tools-version:5.5 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "AsyncSwift", products: [ .executable(name: "AsyncSwift", targets: ["AsyncSwift"]) ], dependencies: [ // none for now.. ], targets: [ .executableTarget(name: "AsyncSwift", swiftSettings: [ .unsafeFlags([ "-parse-as-library", "-Xfrontend", "-disable-availability-checking", "-Xfrontend", "-enable-experimental-concurrency", ]) ] ), .testTarget(name: "AsyncSwiftTests", dependencies: ["AsyncSwift"]), ] )


(4) Edit ${HOME}/AsyncSwift/Sources/AsyncSwift/main.swift
Sources/AsyncSwift/main.swift   Select all
import Foundation func calculateFirstNumber() async -> Int { print("First number is now being calculated...") return await withUnsafeContinuation { c in DispatchQueue.main.asyncAfter(deadline: .now() + 2) { print("First number is now ready.") c.resume(returning: 42) } } } func calculateSecondNumber() async -> Int { print("Second number is now being calculated...") return await withUnsafeContinuation { c in DispatchQueue.main.asyncAfter(deadline: .now() + 1) { print("Second number is now ready.") c.resume(returning: 6) } } } func calculateThirdNumber() async -> Int { print("Third number is now being calculated...") return await withUnsafeContinuation { c in DispatchQueue.main.asyncAfter(deadline: .now() + 3) { print("Third number is now ready.") c.resume(returning: 69) } } } func trace(task: Int) async { // Generates a random integer in the [0, task] range print("Task \(task) started") sleep( UInt32.random(in: 0...UInt32(task)) ) print("Task \(task) completed") } @main struct MyProgram { static func main() async { print("Hello, swift async!\n") print("\nSerial queue, asynchronous execution\n") for i in 5...10 { print("Submitting task \(i)") async { await trace(task: i) } } async let x = calculateFirstNumber() let y = await calculateSecondNumber() let z = await calculateThirdNumber() await print(x + y + z) sleep(2) await print("Program ended") } } /* [6/6] Build complete! Hello, swift async! First number is now being calculated... First number is now ready. Second number is now being calculated... Second number is now ready. Third number is now being calculated... Third number is now ready. 117 */


(5) build and run executable
Shell script for building and running   Select all
cd ${HOME}/AsyncSwift swift package clean swift build swift run


Monday, May 17, 2021

How to compile Quantlib-Python for Raspberry Pi 4B arm32 and arm64

Raspberry Pi has default gcc-8 and Python 3.7 for its 32 bit / 64 bit buster image. And compiling QuantLib-Python on this machine could have out of memeory error. Cross compiling on docker might have different python version which is not compatible. The trick to compile on Raspberry Pi is to setup swap say 2G and 4G Ram and turn off debug -g flag when compiling as Python package.
Shell script for building arm32 version   Select all
# install necessary packages for building sudo apt update sudo apt install -y build-essential wget libbz2-dev libboost-test1.67.0 libboost-test-dev # Get QuantLib-1.22 and build static library cd ${HOME} wget https://github.com/lballabio/QuantLib/releases/download/QuantLib-v1.22/QuantLib-1.22.tar.gz tar xzf QuantLib-1.22.tar.gz cd QuantLib-1.22/ ./configure --prefix=/usr --disable-shared CXXFLAGS=-O3 make -j 4 && make install sudo ldconfig # Setup and enable swap and check it for at least 2GB. sudo dphys-swapfile setup sudo dphys-swapfile swapon free -mh sudo apt install -y python3 python3-pip python-dev libgomp1 # Get QuantLib-SWIG-1.22 and compile it cd ${HOME} wget --no-check-certificate https://github.com/lballabio/QuantLib-SWIG/releases/download/QuantLib-SWIG-v1.22/QuantLib-SWIG-${quantlib_swig_version}.tar.gz tar xfz QuantLib-SWIG-1.22.tar.gz cd QuantLib-SWIG-1.22/ ./configure CXXFLAGS="-O2 --param ggc-min-expand=1 --param ggc-min-heapsize=32768 -Wno-deprecated-declarations -Wno-misleading-indentation" PYTHON=/usr/bin/python3 # manual compile it and remove the -g flag cd Python/ mkdir -p build/temp.linux-armv7l-3.7/QuantLib export CXX="echo gcc"; python3 setup.py bdist_wheel g++ -fwrapv -O2 -Wall -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DNDEBUG -I/usr/include/python3.7m -I/usr/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-armv7l-3.7/QuantLib/quantlib_wrap.o -Wno-unused --param ggc-min-expand=1 --param ggc-min-heapsize=32768 -Wno-deprecated-declarations -Wno-misleading-indentation mkdir -p build/lib.linux-armv7l-3.7/QuantLib/ g++ -shared -Wl,-z,relro -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.7/QuantLib/quantlib_wrap.o -lQuantLib -o build/lib.linux-armv7l-3.7/QuantLib/_QuantLib.cpython-37m-arm-linux-gnueabihf.so # create wheel file python3 setup.py bdist_wheel # Upgrade PIP and install the wheel file /usr/bin/python3 -m pip install --upgrade pip pip3 install dist/QuantLib-1.22-cp37-cp37m-linux_armv7l.whl # Or alternatively install as site-package sudo python3 setup.py install # Test examples after installation pip3 install pandas python3 examples/bonds.py . . . .


Compiling for Rapberry Pi arm64 is very similar but has to add -fPIC flag for the QuantLib when building static library
Shell script for building arm64 version   Select all
# install necessary packages for building sudo apt update sudo apt install -y build-essential wget libbz2-dev sudo apt install -y libboost-test1.67.0 libboost-test-dev cd ${HOME} wget https://github.com/lballabio/QuantLib/releases/download/1.22/QuantLib-1.22.tar.gz tar xzf QuantLib-1.22.tar.gz cd QuantLib-1.22/ # enable -fPIC flag for building static library ./configure --prefix=/usr --disable-shared CXXFLAGS="-O3 -fPIC" make -j 4 && make install sudo ldconfig # If Raspbeery Pi has 8GB Ram, no need to setup and enable swap sudo apt install -y python3 python3-pip python-dev libgomp1 # Get QuantLib-SWIG-1.22 and compile it cd {HOME} wget https://github.com/lballabio/QuantLib-SWIG/releases/download/QuantLib-SWIG-v1.22/QuantLib-SWIG-1.22.tar.gz tar xzf QuantLib-SWIG-1.22.tar.gz cd QuantLib-SWIG-1.22/ cd Python/ ./configure CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768 -fPIC -Wno-deprecated-declarations -Wno-misleading-indentation" PYTHON=/usr/bin/python3 # manual compile it and remove the -g flag cd Python/ mkdir -p build/temp.linux-aarch64-3.7/QuantLib/ g++ -fwrapv -O2 -Wall -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -I/usr/include -c QuantLib/quantlib_wrap.cpp -o build/temp.linux-aarch64-3.7/QuantLib/quantlib_wrap.o -Wno-unused --param ggc-min-expand=1 --param ggc-min-heapsize=32768 -fno-strict-aliasing -Wno-unused -Wno-uninitialized -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-misleading-indentation mkdir -p build/lib.linux-aarch64-3.7/QuantLib/ g++ -shared -Wl,-z,relro -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.7/QuantLib/quantlib_wrap.o -lQuantLib -o build/lib.linux-aarch64-3.7/QuantLib/_QuantLib.cpython-37m-aarch64-linux-gnu.so # create wheel file python3 setup.py bdist_wheel # Upgrade PIP and install the wheel file /usr/bin/python3 -m pip install --upgrade pip pip3 install dist/QuantLib-1.22-cp37-cp37m-linux_aarch64.whl # Or alternatively install as site-package sudo python3 setup.py install # Test examples after installation pip3 install pandas python3 examples/bonds.py


File Download QuantLib-1.22-cp37-cp37m-linux_armv7l.whl https://mega.nz/file/mtJSxZTT#fzDDHw0AIqz-2LIspBGNZLoyW4_MT9qjft_b-ITTA8w

File Download QuantLib-1.22-cp37-cp37m-linux_aarch64.whl https://mega.nz/file/WlAEXJCZ#UKFnlTrfQfRNzFW-OJbXHLFIHwzCw_189HvMa_xU4Oo