English Amiga Board


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

 
 
Thread Tools
Old 27 November 2022, 08:41   #1
felmur
Registered User
 
felmur's Avatar
 
Join Date: Nov 2022
Location: Salerno/Italia
Posts: 16
"undefined reference" error with Gcc ToolChain and MUI38.

Hi all,

I've this problem when I compiling a source with MUI references with Gcc Toolchain.

I've installed the Bebbo Gcc Toolchain (thank you Stefan!) and I've already written and compiled some programs based on intuition & graphics libraries using Eclipse & m68k-amigaos-gcc on my Linux PC.

Now I've started another project using MUI38.

I've copied the amiga MUI38-Developer includes into a folder "mui" under m68k-amigaos directory. I've also add the new include path to project properties.

I was forced to disable optimization (-O0) to prevent "error: asm clobber conflict with
output operand".

The source was built, but after this, I receive some "undefined reference" error from linker.

Anyone can help me?
Regards

This is my source:
Code:
#include <stdio.h>
#include <stdlib.h>


#include <libraries/mui.h>
#include <proto/muimaster.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <libraries/gadtools.h>
#include <libraries/iffparse.h>
#include <stdio.h>
#include <proto/intuition.h>
#include <proto/graphics.h>

#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))

#define IPTR ULONG

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *MUIMasterBase;

BOOL Open_Libs(void)
{
  if ( !(IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",39)) )
    return(0);

  if ( !(GfxBase=(struct GfxBase *) OpenLibrary("graphics.library",0)) )
  {
    CloseLibrary((struct Library *)IntuitionBase);
    return(0);
  }

  if ( !(MUIMasterBase=OpenLibrary(MUIMASTER_NAME,19)) )
  {
    CloseLibrary((struct Library *)GfxBase);
    CloseLibrary((struct Library *)IntuitionBase);
    return(0);
  }

  return(1);
}

void Close_Libs(void)
{
  if (IntuitionBase)
    CloseLibrary((struct Library *)IntuitionBase);

  if (GfxBase)
    CloseLibrary((struct Library *)GfxBase);

  if (MUIMasterBase)
    CloseLibrary(MUIMasterBase);
}



int main(int argc,char *argv[])
{
	Object *app,*win1,*closeButton;
	ULONG signals;
	BOOL running = TRUE;

	if (!Open_Libs())
	{
		printf("Cannot open libs\n");
		return(0);
	}

	app = ApplicationObject,
		MUIA_Application_Title      , "Project",
		MUIA_Application_Version    , "$VER: Project X.X (XX.XX.XX)",
		MUIA_Application_Copyright  , " ",
		MUIA_Application_Author     , " ",
		MUIA_Application_Description, " ",
		MUIA_Application_Base       , " ",

		MUIA_Application_Window, win1 = WindowObject,
			MUIA_Window_Title, "Window Title",
			MUIA_Window_ID   , MAKE_ID('E','M','R','T'),
			WindowContents, VGroup,
				Child, MUI_MakeObject(MUIO_Label,"I am MUI Application on Amiga 3.X",NULL),
				Child, MUI_MakeObject(MUIO_HBar,8),
				Child, closeButton=MUI_MakeObject(MUIO_Button, "Quit", NULL),
			End,
		End,
	End;

	if (!app)
	{
	printf("Cannot create application.\n");
	return(0);
	}

        DoMethod(win1, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
          app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(closeButton, MUIM_Notify, MUIA_Pressed, FALSE,
          app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

    	set(win1,MUIA_Window_Open,TRUE);// open window

	while(running)
	{
		ULONG id = DoMethod(app,MUIM_Application_Input,&signals);

		switch(id)
		{
				case MUIV_Application_ReturnID_Quit:
					if((MUI_RequestA(app,0,0,"Quit?","_Yes|_No","\33cAre you sure?",0)) == 1)
						running = FALSE;
				break;
		}
		if(running && signals) Wait(signals);
	}

	set(win1,MUIA_Window_Open,FALSE);

    if(app) MUI_DisposeObject(app);
	Close_Libs();
	exit(TRUE);
}
This is the gcc toolchain compiler output:

Code:
make all 
Building file: ../src/project.c
Invoking: Cross GCC Compiler
m68k-amigaos-gcc -I/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/project.d" -MT"src/project.o" -o "src/project.o" "../src/project.c"
In file included from /mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/proto/muimaster.h:6:0,
                 from ../src/project.c:6:
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_DisposeObject':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:93:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_FreeAslRequest':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:111:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_FreeClass':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:120:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_Redraw':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:173:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_RejectIDCMP':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:183:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_RequestIDCMP':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:219:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_RemoveClipping':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:261:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_RemoveClipRegion':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:288:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_EndRefresh':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:313:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h: In function 'MUI_ReleasePen':
/mnt/sdb1/AmigaDev/am-gcc/m68k-amigaos/mui/include/inline/muimaster.h:340:12: warning: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
   register res __asm("d0");
            ^~~
../src/project.c: In function 'Open_Libs':
../src/project.c:26:49: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
   if ( !(IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",39)) )
                                                 ^~~~~~~~~~~
../src/project.c:29:37: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
   if ( !(GfxBase=(struct GfxBase *) OpenLibrary("graphics.library",0)) )
                                     ^~~~~~~~~~~
../src/project.c:35:24: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
   if ( !(MUIMasterBase=OpenLibrary(MUIMASTER_NAME,19)) )
                        ^~~~~~~~~~~
../src/project.c: In function 'main':
../src/project.c:96:9: warning: implicit declaration of function 'DoMethod' [-Wimplicit-function-declaration]
         DoMethod(win1, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
         ^~~~~~~~
Finished building: ../src/project.c
 
Building target: project
Invoking: Cross GCC Linker
m68k-amigaos-gcc -g -noixemul -o "project" ./src/project.o   
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `MUI_NewObject':
./src/project.o:(.text+0x64): undefined reference to `MUI_NewObjectA'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `MUI_Request':
./src/project.o:(.text+0x9a): undefined reference to `MUI_RequestA'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `main':
./src/project.o:(.text+0x52a): undefined reference to `MUI_RequestA'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `MUI_AslRequestTags':
./src/project.o:(.text+0x2a): undefined reference to `MUI_AslRequest'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `MUI_AllocAslRequestTags':
./src/project.o:(.text+0x10): undefined reference to `MUI_AllocAslRequest'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `MUI_MakeObject':
./src/project.o:(.text+0x4a): undefined reference to `MUI_MakeObjectA'
/mnt/sdb1/AmigaDev/am-gcc/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ./src/project.o: in function `main':
./src/project.o:(.text+0x5b0): undefined reference to `MUI_DisposeObject'
collect2: error: ld returned 1 exit status
make: *** [makefile:43: project] Errore 1
"make all" terminated with exit code 2. Build might be incomplete.

11:09:02 Build Failed. 15 errors, 14 warnings. (took 211ms)
felmur is offline  
Old 27 November 2022, 09:52   #2
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 681
First: you have to link against libmui.a by adding `-lmui` to your command line.

Plus if you are using amiga-gcc you should install the mui sdk via
Code:
make sdk=mui
PS: please shorten or remove your message in the other thread. Thanks
bebbo is offline  
Old 27 November 2022, 10:09   #3
felmur
Registered User
 
felmur's Avatar
 
Join Date: Nov 2022
Location: Salerno/Italia
Posts: 16
Quote:
Originally Posted by bebbo View Post
First: you have to link against libmui.a by adding `-lmui` to your command line.

Plus if you are using amiga-gcc you should install the mui sdk via
Code:
make sdk=mui
Thanks, I'll try it immediately.
felmur is offline  
Old 27 November 2022, 12:11   #4
felmur
Registered User
 
felmur's Avatar
 
Join Date: Nov 2022
Location: Salerno/Italia
Posts: 16
Yes, it works. Thank you Stefan.

So, the necessary steps to compile a source using MUI with the Gcc-Toolchain under linux are:
1) You MUST NOT import MuiDeveloper38 includes into gcc-toolchain includes. So you should NOT add include path to your Eclipse project.
2) in the amiga-gcc toolchain directory, the one where you compiled the gcc-toolchain, you need to create the includes and the libmui.a library. To do this, from the shell type:
Code:
make sdk=mui PREFIX=<your installation prefix>
3) To your Eclipse project add "mui" in Properties->C/C++ Build->Settings->Cross Gcc Linker->Libraries(-l).
felmur is offline  
Old 27 November 2022, 13:01   #5
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 681
Quote:
Originally Posted by felmur View Post
Yes, it works. Thank you Stefan.

So, the necessary steps to compile a source using MUI with the Gcc-Toolchain under linux are:
1) You MUST NOT import MuiDeveloper38 includes into gcc-toolchain includes. So you should NOT add include path to your Eclipse project.
2) in the amiga-gcc toolchain directory, the one where you compiled the gcc-toolchain, you need to create the includes and the libmui.a library. To do this, from the shell type:
Code:
make sdk=mui PREFIX=<your installation prefix>
3) To your Eclipse project add "mui" in Properties->C/C++ Build->Settings->Cross Gcc Linker->Libraries(-l).

congarats!


And if you are using `-noixemul` you can omit
- recerencing/defining the LibBases
- opening the libs
- closing the libs


since `-noixemul` provides an autoopen/-close feature.
bebbo 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
VBCC "kick13" error in "exec\interrupts.h" Cyprian Coders. C/C++ 8 12 August 2022 23:44
VLINK doubts: Can't reference "re-linked" symbols? Hcktrox Coders. Asm / Hardware 3 17 December 2017 18:57
vasm "undefined symbol" is driving me nuts jotd Coders. Asm / Hardware 6 03 December 2017 20:17
Playing "Legend of Faerghail", suddenly "Software error - Task Held"? arto support.WinUAE 12 05 January 2016 18:07
"Exception "Line 1111 Emulator" ($2c) Error at $1004" when exiting game demolition support.WinUAE 15 30 November 2012 16:43

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 03:30.

Top

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