PS4SDKs & Setup

There are currently 2 publicly available PS4 SDKs the 1st being Cturt's SDK & Hito's SDK, so which one should you use?

for fork numbers out there you'd be more inclined to go with Cturt's SDK as it has 139 forks compared to only 13 for Hito's but that doesn't tell you the half the§ story.

I'm gonna keep this argument simple, Hito's SDK while still lacking is more complete, in that it's headers contain both FreeBSD(PS4 is based on FreeBSD) and a subset of PS4 headers, while Cturt's seems for the most part to only contain PS4 headers.
There is also the way both SDK's resolve symbols, in Cturt's SDK if you wanted to use any library you need to initialise that library yourself e.g. initLibc(); while Hito's does it automatically, as such the code flows much like it would when you're working on a "Desktop" code.

But what does that mean, it mean with Hito's SDK I am able to build freetype2 library from upstream without any modifications, while I wouldn't be able to with Cturt's.

Just so as of now all the tools that @bigboss has created are based on Hito's SDK, the library I released is based on Hito's as well and any future release of mine is likely to continue with this trend, to add to that @masterzorag recently released a font library to complement bigboss's libraries aswell, and as such by default he's using Hito's SDK. With that said I say this with 99.95% certainty that Hito's SDK will be the mainstream PS4 SDK for the homebrew community as they both stand right now. Now with that out of the way, you probably guessed which SDK I'll be talking about from now on.

( P.S if you're doing official work which will go on to be released on the PSN, you're reading the wrong article my friend XD )

The juicy stuff

Quick note: if you're running Ubuntu you'd most likely get away with using the default clang compiler, if you're contempt with that you'll only have to go through Setting up the SDK - Initial Step & call make at the end in $PS4SDK but I'm trying to create a mostly self contained toolchain, as such I will be building clang from source.(If you're not building clang from source, you'll need to modify the cmake toolchain script to work with your setup)

If you're running OSX you will have not choice but to build clang from source and so the following steps will be valid for both Linux based OSes and OSX.

Setting up the SDK - Initial Step

  • this will clone hito's SDK and cherry-pick changes introduced by bigboss which are needed for homebrew development
cd ~
git clone
cd ps4sdk
  • The following block is optional in terms of getting the sdk setup, but will be required if you plan to create homebrew with any type of interface or gamepad support.
git remote add bigboss
git fetch bigboss
git cherry-pick 2c2739d7a1dfeb1f58f496a313bbdce62db2570e
  • The next set of commands will setup ./usr directory which will contain everything related the the PS4SDK, turning it onto a self contained toolchain
mkdir lib; mkdir usr; cd usr;
ln -s $PS4SDK/lib lib
ln -s $PS4SDK/include include
cd ..
  • if you're Ubuntu/Linux user open ~/.bash_aliases using your favourite editor and add this line to it
    • export PS4SDK=/location/to/ps4sdk
    • this will save you the hassle of having to define $PS4SDK everytime you open your shell terminal
  • if you're on OSX
    • you might need to create .bash_profile and .bash_aliases in ~/
      • in .bash_profile add the following
      if [ -f ~/.bash_aliases ]; then
      . ~/.bash_aliases
      • in .bash_aliases add
      export PS4SDK=/location/to/ps4sdk
  • close the terminal and open a new window to make sure this worked correctly, to confirm just do echo $PS4SDK and that should printout the location of the SDK
  • for now you're done with the SDK, but you'll return to it later to build the libraries at the very end

Building Clang From Source

  • building clang is actually straight forward process
  • the following site of commands would clone the required repo to build clang
cd $PS4SDK
mkdir -p EXPT/crossllvm
cd EXPT/crossllvm
git clone
cd llvm/tools
git clone
git clone
cd ../projects
git clone
cd ..
  • while the following lines setup the build
mkdir build; cd build
  • finally these lines start the build
# Ubuntu:
export PM=$(grep -c processor /proc/cpuinfo)
# OSX:
export PM=4

make -j${PM}
make install -j${PM}
  • build time will vary based on your PC specs
    • My Ryzen 7 1700 took ~20mins on 16 threads
    • My Macbook Air i5 took ~an hour on 4 threads

Building binutils From Source

  • the following few lines will clone, setup build, build and install binutils to your PS4SDK
git clone git:// binutils
cd binutils
./configure --prefix="$PS4SDK/usr" --target="x86_64-pc-freebsd9" 
make install
  • next you'd just need to rename ld to orbis-ld and have a copy in ./usr/bin/
    • (I wouldn't recommend copying bins to /usr/bin manually in your regular setup but since this is a standalone isolated from system bins there isn't much harm to be done)
cd $PS4SDK/usr/x86_64-pc-freebsd9/bin
cp ld orbis-ld
cp -R $PS4SDK/usr/x86_64-pc-freebsd9/lib/ $PS4SDK/usr/lib/
cp -R $PS4SDK/usr/x86_64-pc-freebsd9/bin/* $PS4SDK/usr/bin/

Setting up the SDK - Final Setup

  • check that you're using the correct clang by typing clang -v in the terminal and you should get something like this
clang version 6.0.0 ( ca559e03cc2cedb2c76340f055f784dddac9f83f) ( f8e00e2dc29429bf81f0e437c7e96750f05d62f5)
Target: x86_64-scei-ps4
Thread model: posix
InstalledDir: /home/zer0/ps4sdk//usr/bin
  • Note Target: x86_64-scei-ps4
    • if you didn't get that type PATH=$PS4SDK/usr/bin:$PATH and try again
  • if everything checks out continue with cd $PS4SDK then make -j{PM}
    • Ubuntu: there is no harm in running export PM=$(grep -c processor /proc/cpuinfo) again to make sure it's set before calling make -j{PM}

    • OSX: export PM=4 then callmake -j{PM}

    • give it few minutes and you're all set

Start building with SDK

you can do this directly with Makefile or CMake.
My personal advise is cmake

  • cmake
    • instructions have been posted in this article and you can skip to "download PS4-CMake-Toolchain" under "How-To-Use"
  • Makefile
    • Hito has provided few sample projects for us here that you can have a look at
    • but to summaries
      • create a folder for your project e.g PS4Test
      • download this Makefile and place it inside PS4Test
      • create folders include and source inside PS4Test
      • place your headers into include and your code into source
      • Note: if you're using Makefile, you'd need to call PATH=$PS4SDK/usr/bin:$PATH everytime you start your shell terminal to make sure make picks the correct compiler
        • you could set it up like we did earlier for PS4SDK but I highly advise against it, as it can break your native build system


Thanks to bigboss, as this post is directly based on his instructions

You can always contact me @Zer0xFF if you have any quaries, questions or concerns.