PS3 How do i compile a sprx project with libc and libstdc++?

StarmanX32

Member
Hi everyone,

I'm playing a little bit around with the sdk and I've successfully built my first sprx and ran it as a VSH plugin using only PS3 libraries. However, when I try to use a libc function (although i've specified the path in the additional dependencies), it just gives me undefined reference errors. I've also tried C++ libraries like iostream, but it gave me the same linking error. :/

I've heard (can't remember the name) from a dev, that it's painful to link libc into the project... Has anyone a solution for this? (Another friend also has this issue and has no solution ready..)
 
Hi everyone,

I'm playing a little bit around with the sdk and I've successfully built my first sprx and ran it as a VSH plugin using only PS3 libraries. However, when I try to use a libc function (although i've specified the path in the additional dependencies), it just gives me undefined reference errors. I've also tried C++ libraries like iostream, but it gave me the same linking error. :/

I've heard (can't remember the name) from a dev, that it's painful to link libc into the project... Has anyone a solution for this? (Another friend also has this issue and has no solution ready..)
The libc library offered in the sdk is for self projects (and sprx projects used with a self) however the sdk was never meant to produce sprx files for vsh.self which uses a somewhat different libc implementation ie the libc functions are spread into different modules, some stuff in stdc, some in allocator, some in sysPrxForUser etc... As a result if you use only the libc_stub.a library, you should be able to link your project but it will crash when run on PS3 because the system won't be able to find the correspondences the linker established at compile time.
There is only a partial solution for C which is to use the vsh exports (stdc, allocator..), however you can forget about using C++ stuff unless you are ready for some serious job finding all needed exports, setting them up for proper class inheritance & implementing yourself whatever you cannot find.
There are 2 ways to use vsh exports in a prx project:
1. use the vsh export headers & stubs libraries to link your code (available in the webMAN-MOD repo https://www.github.com/aldostools/webMAN-MOD)
2. hook the needed vsh exports at runtime.
 
Last edited:
The libc library offered in the sdk is for self projects (and sprx projects used with a self) however the sdk was never meant to produce sprx files for vsh.self which uses a somewhat different libc implementation.
There is only a partial solution for C which is to use the vsh exports (stdc, allocator..), however you can forget about using C++ stuff unless you are ready for some serious job finding all needed exports, setting them up for proper class inheritance & implementing yourself whatever you cannot find.
There are 2 ways to use vsh exports in a prx project:
1. use the vsh export headers & stubs libraries to link your code (available in the webMAN-MOD repo https://www.github.com/aldostools/webMAN-MOD)
2. hook the needed vsh exports at runtime.

Thanks for your answer, i'll try that out with the vsh export stubs. :)
 
@StarmanX32
In my repo libc.c has some wrappers for VSH exports (but also some functions are coded but commented out)
https://github.com/aldostools/webMAN-MOD/blob/master/libc.c

The stubs are found in this folder:
https://github.com/aldostools/webMAN-MOD/tree/master/lib

The classes for VSH exports are found in this folder:
https://github.com/aldostools/webMAN-MOD/tree/master/vsh

In the repo you will find various project examples of sprx code (some are very basic):
1. https://github.com/aldostools/webMAN-MOD/blob/master/_Projects_/video_rec (Standalone video recorder starter)
2. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/vsh_menu (VSH Menu)
3. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/slaunch (sLaunch: full screen menu)
4. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/netiso (Redirect SCSI commands to ps3netsrv)
5. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/rawseciso (Redirect SCSI to sys storage I/O)
6. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/wm_proxy (Proxy to redirect XMB actions to http)
7. https://github.com/aldostools/webMAN-MOD (Main project)

Plugins 1-6 are launched by webMAN MOD dynamically using cobra_load_vsh_plugin (Cobra opcode 0x1EE7)
 
@StarmanX32
In my repo libc.c has some wrappers for VSH exports (but also some functions are coded but commented out)
https://github.com/aldostools/webMAN-MOD/blob/master/libc.c

The stubs are found in this folder:
https://github.com/aldostools/webMAN-MOD/tree/master/lib

The classes for VSH exports are found in this folder:
https://github.com/aldostools/webMAN-MOD/tree/master/vsh

In the repo you will find various project examples of sprx code (some are very basic):
1. https://github.com/aldostools/webMAN-MOD/blob/master/_Projects_/video_rec (Standalone video recorder starter)
2. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/vsh_menu (VSH Menu)
3. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/slaunch (sLaunch: full screen menu)
4. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/netiso (Redirect SCSI commands to ps3netsrv)
5. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/rawseciso (Redirect SCSI to sys storage I/O)
6. https://github.com/aldostools/webMAN-MOD/tree/master/_Projects_/wm_proxy (Proxy to redirect XMB actions to http)
7. https://github.com/aldostools/webMAN-MOD (Main project)

Plugins 1-6 are launched by webMAN MOD dynamically using cobra_load_vsh_plugin (Cobra opcode 0x1EE7)

Ok, I'm trying out that now.

So basically, I have to add the path for the vsh stubs to the additional dependencies.
Put the vsh header files into the header section in my sprx project
put libc into the source file folder

and then i can use these functions?
 
Ok, I'm trying out that now.

So basically, I have to add the path for the vsh stubs to the additional dependencies.
Put the vsh header files into the header section in my sprx project
put libc into the source file folder

and then i can use these functions?

Check the project for video_rec plugin.

Makefile has the references to the stubs files (lib\*_stub.a) and the classes (inc\*.h):
PPU_INCDIRS += -I./vsh/inc
PPU_PRX_TARGET = video_rec.prx
PPU_PRX_LDFLAGS += -L./vsh/lib -Wl,--strip-unused-data

PPU_PRX_LDLIBS += -lfs_stub -lio_stub -lrtc_stub \
-lvsh_export_stub \
-lpaf_export_stub \
-lvshmain_export_stub \
-lvshtask_export_stub \
-lallocator_export_stub \
-lstdc_export_stub \
-lxsetting_export_stub

main.c has #include "vsh_exports.h"
That file includes all the classes for the vsh exports used by the project.

After that include, several functions like vshtask_notify found in the include vshtask.h or c functions found in stdc.h can be used in the project.
 
Check the project for video_rec plugin.

Makefile has the references to the stubs files (lib\*_stub.a) and the classes (inc\*.h):
PPU_INCDIRS += -I./vsh/inc
PPU_PRX_TARGET = video_rec.prx
PPU_PRX_LDFLAGS += -L./vsh/lib -Wl,--strip-unused-data

PPU_PRX_LDLIBS += -lfs_stub -lio_stub -lrtc_stub \
-lvsh_export_stub \
-lpaf_export_stub \
-lvshmain_export_stub \
-lvshtask_export_stub \
-lallocator_export_stub \
-lstdc_export_stub \
-lxsetting_export_stub

main.c has #include "vsh_exports.h"
That file includes all the classes for the vsh exports used by the project.

After that include, several functions like vshtask_notify found in the include vshtask.h or c functions found in stdc.h can be used in the project.

Thanks for the response, it was very helpful! :)
 
Back
Top