How to link to functions in the PS5 SDK (from C++)?

Basic question that I feel I must just be not managing to find an answer to in the UE docs somehow. I’m building Unreal Engine 5 from source, and have a “Gameplay” module we write much of our code into. Somewhere in here, I’m trying to call PS5 SDK methods like sceSomeFunctionName() and friends. Not that this will live in the gameplay module forever, but just to test if I even can call PS5 SDK functions, and start poking at that. But, while I’m able to #include <scebase_common.h>, I’m getting a linker error due to not finding the definition of these SDK functions. (Just for completeness, happen to be using Visual Studio to build. Which I am able to do in general.) I’m betting there’s some Gameplay.Build.cs modification required so I can link to the SDK’s functions. But… what are these modifications? I haven’t found a basic PS5 SDK + UE5 (from code) getting-started sort of page anywhere to let me know what this needs to be.

1 Like

Solved by a friendly Sony dev. There are a few parts to this.

  1. UEBuildPS5.cs already takes care of adding necessary paths for you.
  2. Ensure your plugin is only being built for PS5 targets (or that your PS5-specific YourPlugin.Build.cs work and any uses of PS5 SDK functions are ifdef’d to only be for PS5 targets). If you’re taking the whole-plugin approach, you can add "SupportedTargetPlatforms": ["PS5"], to YourPlugin.uplugin.
  3. In YourPlugin.Build.cs, tell the linker which PS5 SDK bits it’ll need to link to. This looks like PublicSystemLibraries.Add("SceErrorDialog_stub_weak"). Note you do not add the .a/.o suffix, you do not add the “lib” prefix, and you do not specify any path information. See the PS5 SDK docs for other library names. Documentation on functions provided by the SDK will specify what you need to link to.
  4. This part isn’t for linking, but just for completeness, be sure in your source file that you also #include <error_dialog.h> (or scebase_common.h, etc.; see the docs for what functions you’re using).

If you’re using Visual Studio, don’t forget to close it completely out, make the edits above, GenerateProjectFiles.bat, then open Visual Studio again.

1 Like

Hi, may I know more detail for how to implement ps5 header files to my UE project?
I try using a module to include the PS5 sdk path, but its got a lot of errors when I’m trying to compile.