English Amiga Board


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

 
 
Thread Tools
Old 19 June 2024, 16:06   #1
Emufr3ak
Registered User
 
Join Date: Mar 2016
Location: Thun / Switzerland
Posts: 62
Problem Loading Library

Hi Amiga Coders


Trying to use some Math Libraries. The expected result from the test code below would be an endless loop when the library was loaded. This doesn't work however. I get straight back to console.



I'm running this against a vanilla Amiga 1200 Configuration in the Emulator with nothing installed. It's compiled using the Vscode Plugin from Abyss.


If I remove

MathIeeeSingBasBase= (structMathIEEEBase*) OpenLibrary((CONST_STRPTR)"mathieeesingbas.library", 0);
if (!MathIeeeSingBasBase)
Exit(0);


I'm getting the Endless loop. So I believe that's where the code fails.


Any Ideas?



SysBase=*((structExecBase**)4UL);
custom= (structCustom*)0xdff000;

// We will use the graphics library only to locate and restore the system copper list once we are through.
GfxBase= (structGfxBase*)OpenLibrary((CONST_STRPTR)"graphics.library",0);
if (!GfxBase)
Exit(0);

// used for printing
DOSBase= (structDosLibrary*)OpenLibrary((CONST_STRPTR)"dos.library", 0);
if (!DOSBase)
Exit(0);

MathIeeeSingBasBase= (structMathIEEEBase*) OpenLibrary((CONST_STRPTR)"mathieeesingbas.library", 0);
if (!MathIeeeSingBasBase)
Exit(0);



while (TRUE)
{
/* code */
}




CloseLibrary((structLibrary*)DOSBase);
CloseLibrary((structLibrary*)GfxBase);
Emufr3ak is offline  
Old 19 June 2024, 16:31   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,065
This is a ROM library, so... here comes a blink kick ><.
It's not opened automatically during boot etc., so maybe out of memory? How much is left after you've started your program?
a/b is offline  
Old 19 June 2024, 16:50   #3
Emufr3ak
Registered User
 
Join Date: Mar 2016
Location: Thun / Switzerland
Posts: 62
This is basically all my program is doing. There's a main loop around it but that's it.
Emufr3ak is offline  
Old 19 June 2024, 17:11   #4
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,678
Does this compiler use 16-bit ints? That would explain the problem if so.

Last edited by Minuous; 19 June 2024 at 17:17.
Minuous is offline  
Old 19 June 2024, 17:15   #5
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,065
Post exe? I'm not sure what else could go wrong (it's C and not asm, so who knows).
AFAIK load order is memory first, then disk. Thinking about having a disk based library with the same name that requires an FPU and thus fails to load/init. The one in ROM 3.x should handle FPU and no FPU scenario.
Do you have any tool/app that uses that library, and if so does it also fail to start?
In winuae debugger (shift-F12), you can use Tl command to get a list of currently loaded libraries. Does it eventually show up there?
a/b is offline  
Old 19 June 2024, 17:21   #6
Emufr3ak
Registered User
 
Join Date: Mar 2016
Location: Thun / Switzerland
Posts: 62
It's gcc. I think the frameworks using it's own version. I'm not exactly sure where the framework stores the executable for the compiler.
Emufr3ak is offline  
Old 19 June 2024, 17:24   #7
Emufr3ak
Registered User
 
Join Date: Mar 2016
Location: Thun / Switzerland
Posts: 62
Just noticed I made a stupid mistake. I changed my example before posting it. The one above worked.

The issue is with mathieeetransbase. Below example immediately returns to shell

int main() {
SysBase = *((struct ExecBase**)4UL);
custom = (struct Custom*)0xdff000;

// We will use the graphics library only to locate and restore the system copper list once we are through.
GfxBase = (struct GfxBase *)OpenLibrary((CONST_STRPTR)"graphics.library",0);
if (!GfxBase)
Exit(0);

// used for printing
DOSBase = (struct DosLibrary*)OpenLibrary((CONST_STRPTR)"dos.library", 0);
if (!DOSBase)
Exit(0);

MathIeeeSingBasBase = (struct MathIEEEBase *) OpenLibrary((CONST_STRPTR)"mathieeesingbas.library", 0);
if (!MathIeeeSingBasBase)
Exit(0);

MathIeeeSingTransBase = (struct MathIEEEBase *) OpenLibrary("mathieeesingtrans.library",37);
if (!MathIeeeSingTransBase)
Exit(0);


while (TRUE)
{
/* code */
}




CloseLibrary((struct Library*)DOSBase);
CloseLibrary((struct Library*)GfxBase);
}
Emufr3ak is offline  
Old 19 June 2024, 17:35   #8
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,065
That library is always disk based, so it should be present in LIBS:.
a/b is offline  
Old 19 June 2024, 17:54   #9
Emufr3ak
Registered User
 
Join Date: Mar 2016
Location: Thun / Switzerland
Posts: 62
So mathieeesingtrans.library is disk based. That definitely explains it. As it's part of the OS I can expect it to be there on a HD Based System?
Emufr3ak is offline  
Old 19 June 2024, 18:01   #10
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,315
Note that your resource management is flaky. It is not correct to call exit if opening one of the libraries failed to open. You also need to close all those libraries you could open so far. Mathieeesingtrans is in LIBS: on harddisk-based installations, yes.
Thomas Richter is offline  
Old 19 June 2024, 23:19   #11
No.3
Registered User
 
Join Date: Sep 2022
Location: Switzerland
Posts: 120
Quote:
Originally Posted by Thomas Richter View Post
Note that your resource management is flaky. It is not correct to call exit if opening one of the libraries failed to open. You also need to close all those libraries you could open so far.
and it would be nice if an (helpful!) error message would be printed...
No.3 is offline  
Old 24 June 2024, 15:48   #12
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 537
Quote:
Originally Posted by Thomas Richter View Post
Note that your resource management is flaky. It is not correct to call exit if opening one of the libraries failed to open. You also need to close all those libraries you could open so far. Mathieeesingtrans is in LIBS: on harddisk-based installations, yes.
More to the point, calling Exit() as opposed to exit() will skip the program's cleanup operations. You should never ever call Exit() from a 'C' program because it will end up using the shortest possible path to return control to the shell Process which launched it. No allocated signals will be released and no file handles will be closed.
Olaf Barthel 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
Why isn't my A2000 loading Janus.library? (A2286 board) klokwirk support.AmigaOS 34 01 August 2023 20:27
A500/Vampire/Coffin/SDNet - bsdsocket.library loading issues LimpingNinja New to Emulation or Amiga scene 0 13 March 2020 10:47
Library for loading graphics sparhawk Coders. General 2 07 March 2020 20:38
OS41FE Loading Problem Saghalie support.WinUAE 3 15 October 2016 23:16
Problem with 'damage' loading Mad Mark support.Games 1 23 March 2002 18:40

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 04:51.

Top

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