This directory contains sample programs demonstrating various features of the Xbyak JIT assembler library.
CMake provides cross-platform build support for Windows, Linux, and macOS.
mkdir build cd build cmake .. cmake --build . --config Release
#clean build cmake --build . --target clean #clean then build (Recommended) cmake --build . --clean-first --config Release
# Delete build directory and reconfigure rm -rf build mkdir build cd build cmake .. cmake --build . --config Release
On Windows:
.\bin\Release\test_util64.exe .\bin\Release\test64.exe .\bin\Release\bf64.exe
On Linux/macOS:
./bin/test_util64 ./bin/test64 ./bin/bf64
# Build only test_util64 cmake --build . --config Release --target test_util64 # Build only profiler cmake --build . --config Release --target profiler
To build 32-bit targets on a 64-bit Linux system, you need multilib support:
# Install multilib (Ubuntu/Debian) sudo apt-get install gcc-multilib g++-multilib # Configure with 32-bit targets enabled cmake -DBUILD_32BIT_TARGETS=ON .. cmake --build . --config Release
This will build additional 32-bit versions: test, bf, toyvm, test_util, memfunc, static_buf, jmp_table, and calc (if Boost is available).
The calc and calc64 targets require Boost libraries. CMake will automatically detect Boost and build these targets if available.
Installing Boost:
sudo apt-get install libboost-all-devbrew install boostBUILD_32BIT_TARGETS=ON/OFF - Enable 32-bit target builds (default: OFF, Linux 64-bit only)BUILD_PROFILER_VTUNE=ON/OFF - Build profiler with VTune support (default: OFF, requires Intel VTune)# Example with options cmake -DBUILD_32BIT_TARGETS=ON -DBUILD_PROFILER_VTUNE=ON ..
# Build all targets make # Build specific target make test64 make bf64 make test_util64 # Clean make clean
The Makefile automatically detects:
Individual Visual Studio project files are provided for quick builds on Windows.
.vcxproj file in Visual StudioAvailable project files:
bf.vcxproj - Brainf*ck interpretercalc.vcxproj - Calculator (requires Boost)calc2.vcxproj - Alternative calculator (requires Boost)quantize.vcxproj - Quantization exampletest0.vcxproj - Basic teststest_util.vcxproj - CPU utilitytoyvm.vcxproj - Toy VM# Build with MSBuild msbuild test0.vcxproj /p:Configuration=Release /p:Platform=x64 # Or use the solution file if available msbuild xbyak_samples.sln /p:Configuration=Release
If Boost is installed but not detected:
cmake -DBOOST_ROOT=/path/to/boost ..
Install the C++ standard library:
sudo apt-get install libstdc++-dev
This should be handled automatically by CMake. If issues persist, ensure pthreads is available:
sudo apt-get install libpthread-stubs0-dev
These targets are Linux-specific and use Linux memory mapping APIs. They are automatically excluded on Windows.
*64 suffix indicates 64-bit builds. 32-bit builds have no suffix.static_buf and memfd) only work on Linuxcalc samples require Boost.Spirit and are only built if Boost is detected../test/CFLAGS_WARN.cfg (GCC/Clang only)Several Brainf*ck programs are included:
# On Windows .\build\bin\Release\bf64.exe echo.bf .build\bin\Release\bf64.exe hello.bf .build\bin\Release\bf64.exe fizzbuzz.bf # On Linux ./build/bin/bf64 echo.bf ./build/bin/bf64 hello.bf ./build/bin/bf64 fizzbuzz.bf