Niotso - Compile guide

From Niotso Wiki
Jump to: navigation, search

This page walks you through the steps to compiling the entire Niotso codebase for your target platform.

No proprietary software of any kind is required.

Windows[edit]

  • Install Git, preferably for Windows cmd (it also installs its own version of bash on the side, even if you select a cmd installation), but (when it asks you) without overwriting the basic Windows commands like find.
  • Install any version of MinGW-builds of your choosing; to do so, extract it in a location such as C:\MinGW64, and then add C:\MinGW64\bin to your environment paths. To perform the latter, click Start, type in "advanced system settings" and press enter (also accessible from Start -> right-click Computer -> Properties -> Advanced system settings), click the Environment Variables... button at the lower right, and in the dialog that comes up, in the lower box (labeled System variables), scroll down to "Path" (case-sensitive), select it, click Edit, and somewhere near the beginning (before Cygwin, Strawberry Perl, Octave, hell even AMD has shipped a version of GCC with their OpenCL SDK; this needs to come before all of them) add "C:\MinGW64\bin;" (don't forget the semicolon). Then click OK to all of these dialogs.
    • We use the "Toolchains targetting Win64/Personal Builds/mingw-builds/<latest version>/threads-win32/sjlj" version of MinGW-builds and use the -m32 flag to compile for 32-bit Windows.
    • To confirm that cmd is reading from the correct version of GCC, close all of the currently opened cmd instances, start a new one, and run "gcc --version". Additionally, you can see all locations of gcc.exe with "where gcc"; yours should come up first.
  • Download glext.h and drop it in C:\MinGW64\x86_64-w64-mingw32\include\GL\. (It's licensed under the MIT license.)
  • Install nasm. Just because it's easier to update it this way (because you most likely don't want two versions of nasm installed concurrently), you should download the zip package of it (rather than the installer) and extract the contents of the bin folder into C:\nasm; you only have to add this location to your environment paths once.
  • In cmd, run:
git config --global core.editor notepad
  • Make a directory somewhere and call it, say, "niotso git", and cd into that folder. Run:
git clone https://github.com/Fatbag/Niotso.git
  • Once it's finished downloading, in the top level of the repository (where the .git folder resides), make four new folders called "_build", "_deps", "_dist", and "_docs" right next to Client, Libraries, and so on. Then you will need to download a few things. Download the binaries and the dependencies for tar and wget from GnuWin32, and download the Windows binary for xzdec from the XZ Utils homepage; extract just the exes and dlls into the _deps folder.
  • Then, again with cmd (not bash/cygwin/MSYS), in the top level of the repository, run:
update-libraries
  • Assuming everything downloaded and extracted without error, cd into the _build folder and run:
cmake -G "MinGW Makefiles" ..
  • Note: This command is case-sensitive. Also, don't forget the "..".

At this point, everything should be set up. From now on, you run mingw32-make inside the _build folder to compile, mingw32-make clean in the _build folder to delete all compiled objects, and whenever you update the repository, update-libraries from the top level of the repository to update the libraries with new ones hosted by Niotso. You can also run mingw32-make -j #, where # is the number of cores on your machine, to speed up the compile process, or mingw32-make VERBOSE=1 to debug include or link errors. Run doxygen Doxyfile from the topmost level of the repository (outside the _build folder) to generate documentation into the _docs folder.

Resolving Windows dependencies[edit]

If you have Chocolatey on your Windows computer, then you may install the above with this simple command:

 cinst cmake mingw nasm git 7zip doxygen

Keep in mind, this process will take some time, and installs in order they were typed.

Cross-compiling from Linux[edit]

The Windows version of Niotso must be statically linked with third-party libraries (libpng, libjpeg-turbo, ...). These must be downloaded with the update-libraries.sh script rather than through your package manager.

  • First things first, install the dependencies.
Debian-based:
apt-get install git gcc gcc-c++ ccache nasm libX11-dev libXxf86vm-dev mesa-libGL-dev mesa-libGLU-dev doxygen make cmake wget xz
Ubuntu-based:
apt-get install git gcc g++ ccache nasm libX11-dev libXxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev doxygen make cmake wget xz-utils
RPM-based:
yum install git gcc gcc-c++ ccache nasm libX11-devel libXxf86vm-devel mesa-libGL-devel mesa-libGLU-devel doxygen make cmake wget xz
Every one of these packages is required; if one is missing, look it up or compile it from source.
  • Make your "niotso git" directory somewhere, cd into it, clone the repository, and then in the top level of the repository (where the .git folder resides), make four new folders called "_build", "_deps", "_dist", and "_docs" right next to Client, Libraries, and so on.
git clone https://github.com/Fatbag/Niotso.git
cd Niotso
mkdir _build
mkdir _deps
mkdir _dist
mkdir _docs
  • From the top level of the repository, run:
./update-libraries.sh
  • Configure cmake for a Windows cross-compile. (As this really hasn't been done before yet, you'll need to learn this part yourself... inform us.)
  • Assuming everything downloaded and extracted without error, cd into the _build folder and run:
cmake -G "Unix Makefiles" ..
  • Note: This command is case-sensitive. Also, don't forget the "..".

At this point, everything should be set up. From now on, you run make inside the _build folder to compile, make clean in the _build folder to delete all compiled objects, and whenever you update the repository, ./update-libraries.sh from the top level of the repository to update the libraries with new ones hosted by Niotso. You can also run make -j #, where # is the number of cores on your machine, to speed up the compile process, or make VERBOSE=1 to debug include or link errors. Run doxygen Doxyfile from the topmost level of the repository (outside the _build folder) to generate documentation into the _docs folder.

Linux[edit]

  • First things first, install the dependencies.
Debian-based:
apt-get install build-essential git gcc gcc-c++ ccache linux-headers nasm libX11-dev libXxf86vm-dev mesa-libGL-dev mesa-libGLU-dev doxygen make cmake freetype freetype-dev libjpeg-turbo libjpeg-turbo-dev libmpg123 libmpg123-dev libpng libpng-dev libpq libpq-dev zlib zlib-dev
Ubuntu-based:
apt-get install build-essential git gcc g++ ccache linux-headers-generic nasm libX11-dev libXxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev doxygen make cmake libfreetype6-dev libfreetype6 libjpeg-turbo8-dev libjpeg-turbo8 libmpg123-0 libmpg123-dev libpng12-0 libpng12-dev zlib1g-dev zlib1g
RPM-based:
yum install git gcc gcc-c++ ccache kernel-headers nasm libX11-devel libXxf86vm-devel mesa-libGL-devel mesa-libGLU-devel doxygen make cmake freetype freetype-devel libjpeg-turbo libjpeg-turbo-devel libmpg123 libmpg123-devel libpng libpng-devel postgresql-libs postgresql-devel zlib zlib-devel
Every one of these packages is required; if one is missing, look it up or compile it from source.
Note that on Fedora, libmpg123 requires the RPMFusion free repository.
  • Make your "niotso git" directory somewhere, cd into it, clone the repository, and then in the top level of the repository (where the .git folder resides), make three new folders called "_build", "_dist", and "_docs" right next to Client, Libraries, and so on.
git clone https://github.com/Fatbag/Niotso.git
cd Niotso
mkdir _build
mkdir _dist
mkdir _docs

Then, in the root directory, run:

chmod +x update-libraries.sh
./update-libraries.sh
  • cd into the _build folder and run:
cmake -G "Unix Makefiles" ..
  • Note: This command is case-sensitive. Also, don't forget the "..".

At this point, everything should be set up. From now on, you run make inside the _build folder to compile and make clean in the _build folder to delete all compiled objects. You can also run make -j #, where # is the number of cores on your machine, to speed up the compile process, or make VERBOSE=1 to debug include or link errors. Run doxygen Doxyfile from the topmost level of the repository (outside the _build folder) to generate documentation into the _docs folder.

Using Valgrind[edit]

Valgrind is essentially for Unix-like OSes only.

  • Start off by installing it.
Debian-based:
apt-get install valgrind
RPM-based:
yum install valgrind
  • Compile Niotso using the Debug profile. (More information later.)
  • You may run any binary through Valgrind by passing its name and arguments, like such:
valgrind ./hitasm -tso -f tsov2.txt

Using gdb[edit]

  • Start off by installing it.
Debian-based:
apt-get install gdb gdb-doc
RPM-based:
yum install gdb gdb-doc
  • Compile Niotso using the Debug profile. (More information later.)
  • You may run any binary through gdb like such:
gdb ./hitasm
run -tso -f tsov2.txt

Others[edit]

Support for Mac OS X is a requirement for grand release, but still not expected for quite some time. Full support for Android, iOS, and possibly others is not expected until after the Niotso grand release, unless we are approached by a maintainer before then. Tech Preview 1 should arrive on Android unless Fatbag runs into problems.