2

I realise there are a lot of questions related to this issue but I couldn't make head nor tale from the ones I read through.

I'm trying to start learning C for the Amiga and decided to have a try following this tutorial: http://www.pcguru.plus.com/tutorial/amiga_c.html

On reaching this point, I'm already running into noob problems:

#include <proto/intuition.h>
#include <intuition/screens.h>
#include <proto/dos.h>
#include <stdio.h>
int main(void) {

   struct Screen *myScreen;
   if (myScreen = LockPubScreen(NULL)) {
        printf("Public Screen locked.\n");
        Delay(100);
        UnlockPubScreen(NULL, myScreen);
        printf("Public Screen unlocked.\n");
   }
   return 0;
}

I'm using the GCC compiler with the following command from the Shell:

gcc -o LockPubScreen LockPubScreen.c

This returns the following:

Warning: assignment makes pointer from integer without a cast
undefined reference to 'LockPubScreen'
undefined reference to 'Delay'
undefined reference to 'UnlockPubScreen

Apart from 'HelloWorld' this is the first attempt at either C or programming the Amiga so I imagine I missing something obvious.

Robert
  • 5,278
  • 43
  • 65
  • 115
  • 4
    By the look of things you're missing the correct `#include` for `LockPubScreen()` (and probably the other two), and are also not linking against the library that defines them. – NPE Jan 24 '13 at 20:49

2 Answers2

3

You probably need to include one or more of these additional files to get the prototype for the functions you're missing:

#include <intuition/gadgetclass.h>
#include <intuition/IntuitionBase.h>
#include <libraries/gadtools.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>

Then, as NPE suggests, may may run into link errors if your compiler doesn't include the requisite library by default, and if you don't specify it.

phonetagger
  • 7,701
  • 3
  • 31
  • 55
  • Thanks for your help. Turns out I had to add `#define __USE_INLINE__` and `struct IntuitionIFace* IIntuition;`. Also had to add `-lauto` to the compiler commands. – Robert Jan 25 '13 at 20:15
  • @Robert - Glad you solved the problem. If my "answer" helped, I'm glad you selected it. If it didn't, then please post what solved your problem as a separate answer, and select your own answer. You won't get any points for selecting your own answer, but if my post didn't help, then it's sort of wrong to select it. – phonetagger Jan 25 '13 at 20:43
  • Your answer did help. you're right that it didn't solve it but it was an important step along the way. =) – Robert Jan 26 '13 at 01:02
3

If you had mentioned that you were trying to compile the program under AmigaOS 4.x, the answer would have been obvious. Library function calls in OS4 must either contain the library interface as well - IIntuition->LockPubScreen(), IDOS->Delay(), etc. - or you must #define __USE_INLINE__ at the beginning of the code.

Trixie
  • 31
  • 1
  • Yes, I realise that now but I had no idea it would make any difference when I posted the question. Thanks for the input; I'm only just starting to dabble in Amiga programming. – Robert Feb 07 '13 at 10:14