- NOTE: The more standard way to build midipix these days is to use this shell script that someone else made https://github.com/lalbornoz/midipix_build
- NOTE: I have started working on PKGBUILDs here: https://github.com/DavidEGrayson/midipix-packages
Let's compile midipix from source and play with it!
-
Get access to a Linux machine for development.
-
Install git and gcc on the development machine.
-
Make the directory
~/midipix_src
for holding source code, and navigate to it. -
Build the cross-compiler with the following command. This could take a while. It produces build files in
~/temp
and puts the compiler files in~/midipix
.git clone git://midipix.org/cbb/cbb-gcc && cd cbb-gcc && ./cbb-midipix-cross-gcc.sh
-
Get the cross-compiler on your PATH:
export PATH=$PATH:~/midipix/bin
-
We now have a working cross-compiler, but it can't do much because we don't have the runtime libraries that the compiled programs need.
-
See the website midipix.org for information about how to get read access to the latest internal/private git repositories. The publicly-available git repos that you can find easily on the site might be too old and not work for you. Then get the source code for the runtime libraries by running the following multi-line command in your shell from the
~/midipix_src
directory. You will need to replace$midipix_internal
with something.for repo in psxtypes pemagine dalist ntapi ntcon ntctty psxscl; do git clone git://midipix.org/$midipix_internal/$repo done
-
Copy
build.sh
from this gist into~/midipix_src
. Run it to update the projects, build them, and install them into the cross-compiler toolchain. -
In some new directory, create a file named
test.c
with a simple "hello world" program:#include <stdio.h> int main() { printf("hello world\n"); return 0; }
-
Compile the program by running the following command. You should probably wrap it in a
Makefile
so you don't have to type it every time.x86_64-nt64-midipix-gcc test.c -o test.exe
-
Copy
test.exe
to a Windows machine. (Actually I do my compilation inside a VirtualBox shared folder that is accessible to both the Linux virtual machine and the Windows host machine so I don't need to bother.) -
Copy all the shared object (*.so) files from
~/midipix/x86_64-nt64-midipix/lib/
to the Windows machine as well, and put them in the same directory astest.exe
so they can be found. (Though for this particular example you should only needlibc.so
andlibpsxscl.so
.) -
Run
.\test.exe
on the Windows machine! If you have MSYS2 installed, I recommend running it from a MinTTY bash shell. If you don't have MSYS2 installed, you can run it from a normal Command Prompt, but beware that you won't actually see the program print anything in the Command Prompt. This is not a bug. To get output from the program, pipe its output to a file using a command like.\test.exe > output.txt
or run it in mintty.
Thanks to the midipix project author for helping me with these instructions.