Objective-C on Dreamcast: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
(Added the tools make section)
(Added the example running and libs base instructions)
 
Line 45: Line 45:
==== Execute the make install command ====
==== Execute the make install command ====
     make install
     make install
== Libs Base ==
==== Clone the repo ====
    git clone git@github.com:andrewapperley/libs-base.git
==== Switch to DC branch ====
    git fetch
    git checkout origin/DC
    git pull
==== Execute the configure command ====
    CC=kos-cc CXX=kos-c++ ./configure --host=sh-elf --target=sh-elf --prefix=/opt/gnustep --enable-nxconstantstring --disable-tls --disable-icu --disable-iconv --disable-libdispatch --disable-xslt --disable-xml --enable-procfs-psinfo --enable-procfs
==== Execute the make command ====
    make
==== Execute the make install command ====
    make install
=Running an example=
Currently the main KOS repo doesn't have pthread support added to master, for now you must have the pthreads branch rebased onto a local branch. I have gone ahead and done this on a personal fork. This shouldn't be the case forever and doing this has it's drawbacks, such as your branch falling behind the active development branch quite easily.
You'll need to take the libgnustep-base.a, libffi.a, and the headers of each library and place them where KOS can find them. This needs to happen every time you alter the source files within those project folders.
==== Switch to Objc branch ====
    git fetch
    git checkout origin/dc-objc
    git pull
==== Execute the examples ====
    make ./examples/dreamcast/objc/runtime
    make ./examples/dreamcast/objc/foundation

Latest revision as of 20:04, 4 August 2024

This article is actively being worked on

Work in progress - items to be added and/or edited: It is subject to change and utilizes repo forks that might be significantly behind the mainline repos.

Introduction

This article will cover the how to setup Objective-C and its Standard Library, Foundation. The following git repos will be used in this guide and will be described in more detail as we go:

  • Tools-Make - provides a set of make files that are used to properly configure Foundation
  • KOS - the main package for making Dreamcast Homebrew. We will need to patch your local git clone with pthread support
  • Libs-Base - provides the Foundation library for Objective-C
  • LibFFI - used for NSTimers and NSInvocation support

Important note: If you haven't setup KOS yet, you must follow the Getting Started Guide. You can then come back and continue with this one.

Preparation

We must first configure and install the prerequisites for Foundation. These include libffi and Tools-Make.

Libffi

Clone the repo

   git clone git@github.com:andrewapperley/libffi.git

Execute the configure command

   CC=kos-cc CXX=kos-c++ ./configure --host=sh-elf --target=sh-elf

Execute the make command

   make

Execute the make install command

   make install

Tools Make

Clone the repo

   git clone git@github.com:andrewapperley/tools-make.git

Switch to DC branch

   git fetch
   git checkout origin/DC
   git pull

Execute the configure command

   CC=kos-cc CXX=kos-c++ ./configure --host=sh-elf --target=sh-elf --prefix=/opt/gnustep --enable-nxconstantstring --disable-tls --disable-icu --disable-iconv --disable-libdispatch --disable-xslt --disable-xml --enable-procfs-psinfo --enable-procfs

Execute the make command

   make

Execute the make install command

   make install

Libs Base

Clone the repo

   git clone git@github.com:andrewapperley/libs-base.git

Switch to DC branch

   git fetch
   git checkout origin/DC
   git pull

Execute the configure command

   CC=kos-cc CXX=kos-c++ ./configure --host=sh-elf --target=sh-elf --prefix=/opt/gnustep --enable-nxconstantstring --disable-tls --disable-icu --disable-iconv --disable-libdispatch --disable-xslt --disable-xml --enable-procfs-psinfo --enable-procfs

Execute the make command

   make

Execute the make install command

   make install

Running an example

Currently the main KOS repo doesn't have pthread support added to master, for now you must have the pthreads branch rebased onto a local branch. I have gone ahead and done this on a personal fork. This shouldn't be the case forever and doing this has it's drawbacks, such as your branch falling behind the active development branch quite easily.

You'll need to take the libgnustep-base.a, libffi.a, and the headers of each library and place them where KOS can find them. This needs to happen every time you alter the source files within those project folders.

Switch to Objc branch

   git fetch
   git checkout origin/dc-objc
   git pull

Execute the examples

   make ./examples/dreamcast/objc/runtime
   make ./examples/dreamcast/objc/foundation