amiga-news DEUTSCHE VERSION
.
Links| Forums| Comments| Report news
.
Chat| Polls| Newsticker| Archive
.

[Login] [Register] [Forgot your password?]

< Next messagePrior message >
29.Oct.2022



AmigaOS 4.1: Introduction to Software Development Kit V54.16, part 2 (update)
Tree weeks ago we had published the first part of the introduction to Hyperion Entertainment's recently updated Software Development Kit (SDK) V54.16 written by Josef Wegner. Now the second part:

"AmigaOS 4.1 SDK 54.16 - How to install it?

In the second article I will show how to install the SDK. Since I unfortunately cannot go into every individual configuration, I assume that AmigaOS 4.1 Final Edition Update 2 is already installed. However, it is irrelevant whether further software or the Enhancer 2.2 is installed.

What is required for the installation?

As mentioned in the first paragraph, update 2 of AmigaOS 4.1 Final Edition should be installed. Besides that you need:
  • enough time; on a PPC Amiga the installation takes 10 - 20 minutes
  • 200 - 920 MB free space on a NGFS or SFS drive (preferably another drive besides the system drive) for the installed SDK
  • 350 - 400 MB additional free space on a (different) drive for unpacking the archive
  • the installation archive
Are there things I should do before installing?

Yes, there are one or two things you should do before you install the SDK installed:

The first thing you should do is make a copy of your S:User startup. Apparently there is a bug in the installer program or installer script, that the last line is deleted from the user startup. After the installation compare both files, and make sure that nothing is missing.

The second thing is, if you have an older SDK installed, you should remove or comment out the old one from your s:User startup file or comment it out. The lines in question are the following ones:

;BEGIN AmigaOS 4.1 SDK
assign SDK: Work:SDK
execute SDK:S/sdk-startup
;END AmigaOS 4.1 SDK

Delete these lines or comment out the assign/excute with a ;. As next you should reboot the Amiga and finally delete or rename the old SDK directory, move it or rename it.

Now it is best to download the installation archive from Hyperion's website and transfer it to the Amiga if necessary. The second step is to unpack the archive to a destination where you have enough space: this can be done with the standard program Unarc of AmigaOS 4.1 or Archiver from the Enhancer 2.2 or the command line tool "LhA". Depending on what is installed. I personally prefer the command line, so I run the following:

13. > Temp: > lha -a x SHARE:SDK-54.16.lha

The option "-a" tells LhA to restore the attributes (date, permissions). "x" stands for extract the files with full path. The last part tells LhA where the installation archive is stored.

Unpacking the installation archive alone takes 3-4 minutes. Enough time to get a coffee for the next step. The next step is to start the installer "Install SDK" in the freshly unpacked directory "SDK_Install":


And then select the components of the SDK:


A full installation with all four GCC versions requires a bit more than 900 MB. On a NG system (SAM, X1000, or X5000) there should be no space problems. On a Classic system you should limit yourself to one of the four GCCs. This saves about 500MB and some time during the the installation. A complete installation with all four GCCs takes about 10 minutes on my X5000. On Classic systems or WinUAE it takes significantly more. After succesfully installed it...


...you should check, if Startup file is fine and if these new lines have been added:

;BEGIN AmigaOS 4.1 SDK
assign SDK: Work:SDK
execute SDK:S/sdk-startup
;END AmigaOS 4.1 SDK

Then you can reboot and skip the following chapter. In the chapter after next we will test the SDK and compile the first program.

What do I do if it didn't work?

Not enough disk space? The safest thing to do is to delete the SDK that you did not finish installing. Then you can either install the SDK with fewer options, install it on a different drive, or clean up the drive and then try again.

Archive error? I had this during an installation. Solution was as above, delete failed attempt and try again.

Error unpacking the installation archive or writing the files? Please make sure that the SDK is installed on a local drive, preferably formatted with SFS or NGFS. Also, please do not use a shared drive in (Win)UAE. If this is already the case and there are still errors, you should check the drive for errors. With NGFS this can be done with the command:

NGFCheck Work:

"Work:" stands for the volume name or the drive.

SDK was installed. What comes next?




Now we can finally use the SDK. In article 1 it was said that the SDK comes with several GCCs and the VBCC. So let's see if all of them work. If at least one GCC is installed, we can see with the following command if the GCC is found and which version of the GCC is currently used:

gcc -v

....gcc version 8.4.0 (adtools build 8.4.0)


The SDK provides several GCCs. How can I change the GCC?

Use the tool "set_defGCC" in SDK:Tools for this. This directory is not in the search path, so you have to open it either with the Workbench or the full path.

sdk:Tools/set_defGCC

A small window appears where you can choose between the four GCC versions. But you can also specify the version directly in the Shell. To do this appends the desired version after the command. To select GCC 11, enter the following in the Shell:

4. > Workbench: > sdk:Tools/set_defGCC 11
4. > Workbench: > gcc -v
...gcc version 11.2.0 (adtools build 11.2.0)

But be careful, you can also choose a GCC that is not installed. In this case the Shell will not find a GCC anymore. To solve this, call the tool again and select an installed GCC. If VBCC is also installed, you can test it with the following command:

vc -v
vc frontend for vbcc (c) in 1995-2020 by Volker Barthelmann
No objects to link

Now we can run the first test program. As usual, we write a HelloWorld program in standard C, which would also compile and run on another system without code changes.

Enter the following lines in the editor of choice and save them somewhere as "hello.c". Please leave out the line numbers!
RAM Disk:Shared/Sources/hello/hello.c
1 #include <stdio.h>
2 int main(void)
3 {
4 printf("Hello World!\n");
5 return (0);
6 }

To compile and start in a Shell, run the following:

For the GCC:
3. > RAM Disk:Shared/Sources/hello > gcc hello.c -o hello
3. > RAM Disk:Shared/Sources/hello > hello
Hello World!

With the VBCC:
3. > RAM Disk:Shared/Sources/hello > vc hello.c -o hello
3. > RAM Disk:Shared/Sources/hello > hello
Hello World!

What have I done?

I don't want to dive too deep into the structure and peculiarities of C here. But I'll try to explain briefly which line does what in the program.
  • Line 1: This is not a C command but a command for the C preprocessor to include another file called stdio.h. The preprocessor prepares the program code for further compilation steps and improves the functionality, spelling and readability of the entered code. Besides including so-called header files, the preprocessor can define constants and replace them later in the code, remove comments, or show and hide code parts (conditional compilation). The file stdio stands for "STanDard Input Output" and contains the function definition for the "printf" method. This method outputs the passed string on the command line. The program would compile and run even without this preprocessor command. However, the compiler would issue warnings.

  • Line 2: This is the declaration of the entry function. So that C knows where the program begins, one must define this differently than with script languages. In C it is done by defining the main function (=main). This must have either the form

    int main(void)
    or
    int main(int argc, char **argv)

    The first form ignores the parameters when calling the program, the second one passes the number of parameters (int argc) and an array of the parameters as C strings are passed to the method.

  • Lines 3 and 6: The curly braces define a code block. With this we tell the compiler that everything in between (line 4 + 5) is part of the function.

  • Line 4: Here we call a method of the C standard library that prints the string on the Shell.

  • Line 5: The keyword "return" sets the return value of the function. A return statement terminates the execution of a function and returns control to the calling function. The value 0 means: okay! You should always set a return value, but it is not required like in Java.
Not everything is needed for an executable program. If you want to have (and ignore) many warnings from the compiler, you can write the program much shorter:

main(void) { printf("Hallo Welt!\n"); }

If C lacks the return or variable type, C simply takes int (integer type).

Known problems
  • I get a GrimReaper when starting the compiled program!

    Try to compile the program on a different drive. This happens for example when you compile the program on a shared host drive under WinUAE. Linking the generated object files fails without any message. What comes out is not a real program, and pretty quickly an invalid PPC assembler command is executed, which brings up the GrimReaper.

  • I tried to debug the test program but get a weird SIGBUS error:

    3. > RAM Disk:Shared/Sources/hello > gcc -gstabs hello.c -o hello
    3. > RAM Disk:Shared/Sources/hello > hello
    Hello World!
    3. > RAM Disk:Shared/Sources/hello > gdb hello
    ....Starting program: /RAM Disk/Shared/Sources/hello/hello...
    ...Program received signal SIGBUS, Bus error.
    0x00000000 in ?? ()
    (gdb)

    This is not an SDK or GDB problem, but a bug in the X5000 kernel. There is a beta kernel where this problem is fixed, but it is not publicly available.
What can I do until the third article is published?

First of all, I'm glad you made it this far. The following links might be interesting: We are done! In the third part we will go a little deeper into the syntax of C."

Update: (29.10.2022, 19:50, dr)

The main developer of the SDK, George 'walkero' Sokianos, has read the tutorial with interest and expresses his thanks for Josef's commitment. He also has three additions that we would like to add here:
  • A lot of information on how the SDK is set up and how the compilers can be used is mentioned in the introduction pdf file that can be found in the installation folder. It would be good for people to read that document if they are not familiar with the SDK.
  • Different GCC versions can be used by using the binary based with the specific version added at its name, i.e. gcc-11 or gcc-6.
  • If AmiCygnix is installed the user must make sure that the lines that are added in user-startup must are before the AmiCygnix lines, so to avoid problems with its software.
(dr)

[News message: 29. Oct. 2022, 06:59] [Comments: 1 - 29. Oct. 2022, 20:10]
[Send via e-mail]  [Print version]  [ASCII version]
< Next messagePrior message >

.
Masthead | Privacy policy | Netiquette | Advertising | Contact
Copyright © 1998-2022 by amiga-news.de - all rights reserved.
.