12-11-2014, 06:12 AM
(This post was last modified: 09-25-2019, 02:32 AM by Seadragon91.)
Hello!
Compiling cuberite on a raspberry pi can take a long time. For this problem I looked for a way to cross compile a raspberry pi version. This tutorial should work on debian and on ubuntu based systems.
You will need a linux system for the compiling process, a raspberry pi image and other things too. If you open the terminal then the location should be by default your home location.
We need to do 3 steps. Let's start.
Install Requirements
Packages that are required. Run this command with sudo or as root:
Required for:
Setting up the gcc cross compiler
Everything completed. Copy the the directory Server to the raspberry pi and test if it's running.
If you have any questions, problems ask.
Good luck,
Seadragon91
Sources used:
http://stackoverflow.com/questions/19162...s-compiler
http://somewideopenspace.wordpress.com/2...pi-wheezy/
http://www.raspberrypi.org/downloads/
Compiling cuberite on a raspberry pi can take a long time. For this problem I looked for a way to cross compile a raspberry pi version. This tutorial should work on debian and on ubuntu based systems.
You will need a linux system for the compiling process, a raspberry pi image and other things too. If you open the terminal then the location should be by default your home location.
We need to do 3 steps. Let's start.
Install Requirements
Packages that are required. Run this command with sudo or as root:
apt-get install cmake lua5.1 gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
Required for:
- gcc-arm-linux-gnueabihf - Contains arm-linux-gnueabihf-gcc. the C Cross Compiler
- g++-arm-linux-gnueabihf - Contains arm-linux-gnueabihf-cpp, the C++ Cross Compiler
- cmake - Building cuberite
- lua5.1 - In a build step, generates the c++ bindings for lua
Setting up the gcc cross compiler
- Open a terminal, create the directory raspberrypi and cd into it
- Inside of the directory raspberrypi, create a directory named rootfs. Now the raspberry pi image is required.
- For mounting the image the offset of the second partition is required. Run this with sudo or as root:
fdisk -l <path to raspberry image>
- Example of the output:
Disk 2019-07-10-raspbian-buster-lite.img: 2 GiB, 2197815296 bytes, 4292608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x17869b7d Device Boot Start End Sectors Size Id Type 2019-07-10-raspbian-buster-lite.img1 8192 532480 524289 256M c W95 FAT32 (LBA) 2019-07-10-raspbian-buster-lite.img2 540672 4292607 3751936 1.8G 83 Linux
- Multiply the second number under start by 512
540672 * 512 = 276824064
- This command has to be run with sudo or as a root user.
mount -o offset=276824064 <path to img file> /mnt
- Run this commands with sudo or as root, to copy the lib and usr (can take a while is over 1,5 GiB big) directory into the raspberrypi/rootfs directory:
cp -r /mnt/lib $HOME/raspberrypi/rootfs cp -r /mnt/usr $HOME/raspberrypi/rootfs
- Run this with sudo or as root, to unmount the raspberry pi image:
umount /mnt
- Create a file named pi.cmake in directory raspberrypi and add this content:
SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-cpp) SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/raspberrypi/rootfs) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- The compiling environment has been setup. Now cd into the cuberite source or clone it if you haven't it
- Inside of raspberrypi create the directory Release and cd into it:
cmake -D CMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake -DCMAKE_BUILD_TYPE=RELEASE ..
- For compiling you can add the number of cores / processors it should use. Run nproc to see how many threads are possible, e.g. 4
make -j<number of cores to use> make - Only uses one thread "make -j4" - Uses up to 4 cores / processors, if available
- If it was successful the executable is inside the directory <path to cuberite>/Server
Everything completed. Copy the the directory Server to the raspberry pi and test if it's running.
If you have any questions, problems ask.
Good luck,
Seadragon91
Sources used:
http://stackoverflow.com/questions/19162...s-compiler
http://somewideopenspace.wordpress.com/2...pi-wheezy/
http://www.raspberrypi.org/downloads/