English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 21 July 2021, 00:00   #1
Firestone
Registered User
 
Firestone's Avatar
 
Join Date: Apr 2013
Location: Norway
Posts: 249
vbcc crosscompiling not compiling examplesources, but works in SAS/C on real hardware

Hi everyone....

I have spent some time during my vacation trying to learn a bit about Amiga C-coding.

I have set up vbcc on my mac, and it's able to compile code for the Amiga. I have tried simple intuition-examples, and it works fine (able to create a program a new window and a menu etc...).

But as soon as I turn to some of the reaction-examples, I'm not able to compile anymore on vbcc. Tried the exact same code on SAS/C and it compiles fine and the program runs on my A3000.

Here is the tutorial source code for a simple reaction window:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <exec/types.h>
#include <exec/memory.h>

#include <intuition/intuition.h>
#include <intuition/icclass.h>
#include <intuition/classes.h>

#include <clib/reaction_lib_protos.h>
#include <proto/intuition.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <utility/tagitem.h>
#include <proto/exec.h>
#include <proto/window.h>
#include <proto/layout.h>

#include <classes/window.h>
#include <gadgets/layout.h>
#include <clib/alib_protos.h>

#include <reaction/reaction.h>
#include <reaction/reaction_macros.h>

enum 
  {
  GID_MAIN=0,
  GID_INTEGER1,
  GID_INTEGER2,
  GID_DOWN,
  GID_UP,
  GID_QUIT,
  GID_LAST
  };
  enum 
  {
  WID_MAIN=0,
  WID_LAST
  };
  enum 
  {
  OID_MAIN=0,
  OID_LAST
  };

int main(void) 
  {
  struct Window *windows[WID_LAST];
  struct Library *WindowBase, *LayoutBase;
  struct MsgPort *AppPort;
  Object *objects[OID_LAST];
  ULONG wait, signal, app, done, result;
  UWORD code;
  
  WindowBase = (struct Library *)OpenLibrary("window.class", 44);
  LayoutBase = (struct Library *)OpenLibrary("gadgets/layout.gadget", 44);
  
  if (!WindowBase || !LayoutBase) {
    printf("A library could not be opened!\n");
    return(30);
  }
  else if (AppPort = CreateMsgPort() )
  {
    objects[OID_MAIN] = WindowObject,
    WA_ScreenTitle, "ReAction",
    WA_Title, "ReAction Window Example",
    WA_Activate, TRUE,
    WA_DepthGadget, TRUE,
    WA_DragBar, TRUE,
    WA_CloseGadget, TRUE,
    WA_SizeGadget, TRUE,
    WA_Width, 200,
    WA_Height, 150,
    WINDOW_IconifyGadget, TRUE,
    WINDOW_IconTitle, "Example",
    WINDOW_AppPort, AppPort,
    WINDOW_Position, WPOS_CENTERMOUSE,
    WINDOW_ParentGroup, VLayoutObject,
      LAYOUT_SpaceOuter, TRUE,
      LAYOUT_DeferLayout, TRUE,
      EndGroup, 
    EndWindow;
  
  if (objects[OID_MAIN]) 
  {
     if (windows[WID_MAIN] = (struct Window *)RA_OpenWindow(objects[OID_MAIN]))
     {
      app = (1L << AppPort->mp_SigBit);
      done = FALSE;
      GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  
      while (!done)
      {
        wait = Wait( signal | SIGBREAKF_CTRL_C | app);
        if (wait & SIGBREAKF_CTRL_C)
        {
          done = TRUE;
        } else {
        while (( result = RA_HandleInput(objects[OID_MAIN], &code)) != WMHI_LASTMSG)
        {
          switch (result & WMHI_CLASSMASK)
          {
            case WMHI_CLOSEWINDOW:
              windows[WID_MAIN]=NULL;
              done=TRUE;
              break;
          }
        } /* End while */
      } /* End if */
    } /* End while */
    DisposeObject(objects[OID_MAIN]);
   } /* End if */
   DeleteMsgPort(AppPort);
  } /* End if */
  
    if (WindowBase) CloseLibrary(WindowBase);
    if (LayoutBase) CloseLibrary(LayoutBase);
    return(0);
   } /* End if */
  } /* End main */

On vbcc on my Mac, this will give the following errors:

Code:
# vc +aos68k -I$NDK_INC -L$NDK_LIB -o reactionwindow reactionwindow.c -lamiga -lauto

amiga.lib(WINDOW_GetClass.asm): In "_WINDOW_GetClass":
Error 21: amiga.lib(WINDOW_GetClass.asm) (window+0x4): Reference to undefined symbol _WindowBase.
amiga.lib(LAYOUT_GetClass.asm): In "_LAYOUT_GetClass":
Error 21: amiga.lib(LAYOUT_GetClass.asm) (layout+0x4): Reference to undefined symbol _LayoutBase.
vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib -mrel $VBCC/targets/m68k-amigaos/lib/startup.o "/var/tmp/tmp.0.o"   -L/Users/firestone/amigadev/NDK39/Include/linker_libs -lamiga -lauto -s -Rshort -L$VBCC/targets/m68k-amigaos/lib -lvc -o reactionwindow failed
Can anyone please explain to me why this compiler is unable to compile this code and why SAS/C is able to?
I know C has envolved, but I have not payed attention to the C-programming world for many years.

I'm using NDK39.
I read this in the ReadMe in the linker_libs directory however:
Quote:
Currently the "reaction.lib" support library for Reaction is only usable
with SAS/C.
Firestone is offline  
Old 23 July 2021, 11:59   #2
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
use global variables for
Code:
  struct Library *WindowBase, *LayoutBase;
bebbo is offline  
Old 23 July 2021, 14:47   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Right. The reaction headers and inlines are there, but it seems that I forgot to add the auto.lib code for their library bases. This will hopefully be fixed with the next release of vbcc including NDK 3.2 support.

In the meantime you could open the Reaction libraries and define their library bases yourself, as bebbo suggested. But in the end the linking will still fail, because the reaction.lib in the NDK 3.9 depends on SAS/C-specific regargs-function names, like
@NewList
. Unfortunately somebody decided to compile the support code in reaction.lib with register arguments...

The problem is reported to the NDK 3.2 team. Also that reaction.lib is completely missing in their last NDK release.
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display problem - works on emulation, not on real hardware robinsonb5 Coders. Asm / Hardware 3 21 January 2018 20:53
Need help compiling FileX in VBCC Ami Coders. General 9 12 February 2016 16:16
On real hardware one CF card works the other doesn't, but... Sim085 support.Hardware 3 20 July 2015 22:26
(Useless benchmark) Dhrystone on Sas C/Gcc/Vbcc alkis Coders. System 3 16 October 2013 13:03
Compiling CLib37 with VBCC 0.9 tnt23 Coders. General 2 29 July 2013 10:28

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:22.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11207 seconds with 15 queries