Post: Creating and Using Static Libraries for PS3
12-16-2016, 03:54 PM #1
(adsbygoogle = window.adsbygoogle || []).push({});

Purpose of this tutorial:
In this tutorial we are going to go over creating and linking static libraries for the PS3 (PPU)
In many projects that I see most people copy over and share a lot of the same code, when this can be avoided by using static/dynamic libraries



What is a Static Library?

A static library is a group of functions and variables that are to be used within other programs, this is somewhat comparable to a DLL except that this is linked at compile time, if you want something more like a DLL then this is where you'd want to use an SPRX which is the PS3 equivalent of a dynamic library.

When should I use a Static Library?

You'd want to use a static library when writing code that you plan to use many times in different projects, this makes moving and reusing code a lot easier than copying over tons of files. This would also be good to do when you want to share some sort of library without exposing all of the code in it.

What do I need to make a Static Library?

You will need...

  • PS3 SDK
  • PS3 Compiler Toolchain (SN SYSTEMS/GCC)
  • SCE VSI (or PPU Static Library Project template)
  • Visual Studio (2008+)


How do I make a Static Library?

Visual Studio:


  1. Open up Visual Studio 2010 (if you don't have VS2010 then download the provided Project Template and install it to your Visual Studio Templates directory, skip to step 6)
  2. Create a new PPU SCE PS3 Project
    You must login or register to view this content.
  3. Click Next
  4. Select PPU static library project and Choose a compiler of your choice. Keep Use Precompiled Header selected
    You must login or register to view this content.
  5. Click Finish
  6. Create a new Source File and matching Header File, name them whatever, I'll go with "API"
  7. Declare your methods and variables within your Header and Create the definitions in your Source file, like the following

    You must login or register to view this content.
    You must login or register to view this content.

  8. Build it and you're done



How do I use a Static Library?



  1. Go to your ELF/PRX Project
  2. Go to Project->Properties->Configuration Properties->Linker->General
  3. Add the path to your static library in Additional Library Directories
  4. Add the name of your static library in Additional Dependencies
    You must login or register to view this content.
  5. Copy the header to your project's directory and include it in your project
  6. Call methods from your library and use variables like normal
    You must login or register to view this content.




Conclusion

That's all for this tutorial. We went over how to create and use static libraries for PPU PS3 projects in Visual Studio. Now you can share your code and whatnot without others seeing the actual source of it all. If you'd like a tutorial on how to do this using make or something else then let me know. If you've got other things you'd like to know or other things you think I could make a tutorial on then let me know.

Downloads

Static Template Project Download: You must login or register to view this content.
Last edited by John ; 12-16-2016 at 03:57 PM.

The following 5 users say thank you to John for this useful post:

2much4u, Hydrogen, Kryptus, Norway-_-1999, SC58
12-16-2016, 07:35 PM #2
Hydrogen
Super Mod
Originally posted by John View Post

Purpose of this tutorial:
In this tutorial we are going to go over creating and linking static libraries for the PS3 (PPU)
In many projects that I see most people copy over and share a lot of the same code, when this can be avoided by using static/dynamic libraries



What is a Static Library?

A static library is a group of functions and variables that are to be used within other programs, this is somewhat comparable to a DLL except that this is linked at compile time, if you want something more like a DLL then this is where you'd want to use an SPRX which is the PS3 equivalent of a dynamic library.

When should I use a Static Library?

You'd want to use a static library when writing code that you plan to use many times in different projects, this makes moving and reusing code a lot easier than copying over tons of files. This would also be good to do when you want to share some sort of library without exposing all of the code in it.

What do I need to make a Static Library?

You will need...

  • PS3 SDK
  • PS3 Compiler Toolchain (SN SYSTEMS/GCC)
  • SCE VSI (or PPU Static Library Project template)
  • Visual Studio (2008+)


How do I make a Static Library?

Visual Studio:


  1. Open up Visual Studio 2010 (if you don't have VS2010 then download the provided Project Template and install it to your Visual Studio Templates directory, skip to step 6)
  2. Create a new PPU SCE PS3 Project
    You must login or register to view this content.
  3. Click Next
  4. Select PPU static library project and Choose a compiler of your choice. Keep Use Precompiled Header selected
    You must login or register to view this content.
  5. Click Finish
  6. Create a new Source File and matching Header File, name them whatever, I'll go with "API"
  7. Declare your methods and variables within your Header and Create the definitions in your Source file, like the following

    You must login or register to view this content.
    You must login or register to view this content.

  8. Build it and you're done



How do I use a Static Library?



  1. Go to your ELF/PRX Project
  2. Go to Project->Properties->Configuration Properties->Linker->General
  3. Add the path to your static library in Additional Library Directories
  4. Add the name of your static library in Additional Dependencies
    You must login or register to view this content.
  5. Copy the header to your project's directory and include it in your project
  6. Call methods from your library and use variables like normal
    You must login or register to view this content.




Conclusion

That's all for this tutorial. We went over how to create and use static libraries for PPU PS3 projects in Visual Studio. Now you can share your code and whatnot without others seeing the actual source of it all. If you'd like a tutorial on how to do this using make or something else then let me know. If you've got other things you'd like to know or other things you think I could make a tutorial on then let me know.

Downloads

Static Template Project Download: You must login or register to view this content.


"I didn't even deserve MOTM"

Bitch where. KappaClaus

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo