English Amiga Board


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

 
 
Thread Tools
Old 18 August 2017, 07:21   #1
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Linking with -lmieee in a shared library

I'm porting a matrix math library I wrote to Amiga for something I'm working on. I want to install it as a shared library. I'm writing it in C and using it from a program written in ASM. I'm using VBCC and the CLib37 example code from Aminet.

I know I need to link it with -lmieee to use the Amiga native floating point libraries but since compiling as a shared library doesn't bring in the C runtime, I've got a problem where compiling it ends up with undefined reference errors.

Code:
vc -nostdlib -lamiga -lmieee -cpu=68020 -fpu=68882 -o matrix.library obj/StartUp.o obj/LibInit.o obj/SampleFuncs.o obj/matrix.o
\amiga-dev\targets\m68k-amigaos\lib\mieee.lib(math/math_ieee/_mieee.c): In "__INIT_1_mieee":
Error 21: \amiga-dev\targets\m68k-amigaos\lib\mieee.lib(math/math_ieee/_mieee.c) (CODE+0x7a): Reference to undefined symbol _exit.
Error 21: \amiga-dev\targets\m68k-amigaos\lib\mieee.lib(math/math_ieee/_mieee.c) (CODE+0x9e): Reference to undefined symbol _exit.
Error 21: \amiga-dev\targets\m68k-amigaos\lib\mieee.lib(math/math_ieee/_mieee.c) (CODE+0xc2): Reference to undefined symbol _exit.
How can I get around this so the C floating-point routines point at the Amiga routines?
LuigiThirty is offline  
Old 18 August 2017, 08:20   #2
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Nevermind, I just added an _exit() that gurus if the fp library crashes and it's happy now.
LuigiThirty is offline  
Old 18 August 2017, 08:59   #3
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Please remove the "-fpu=68882" when "-lmieee" is specified.

Quote:
Originally Posted by vbcc.pdf
mieee.lib

This one uses the C= math libraries. The startup code will always open
MathIeeeSingBas.library, MathIeeeDoubBas.library and MathIeeeDoub-
Trans.library. Float return values are passed in d0, double return values are
passed in d0/d1. A 68000 is sufficient to use this library. You must not specify
-fpu=... when you use this library.
http://server.owl.de/~frank/vbcc/docs/vbcc.pdf
matthey is offline  
Old 18 August 2017, 09:35   #4
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Yeah, I saw that too. I changed out the flags and got it compiling and running with my program



The function names don't appear in Scout but oh well.
LuigiThirty is offline  
Old 18 August 2017, 14:24   #5
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by LuigiThirty View Post
Yeah, I saw that too. I changed out the flags and got it compiling and running with my program
Congrats!

Quote:
Originally Posted by LuigiThirty View Post
The function names don't appear in Scout but oh well.
As I recall, this requires a .fd file for matrix.library and a FD: assign to the location of the .fd files.
matthey is offline  
Old 19 August 2017, 00:41   #6
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
If I fix a bug in the library, is there a way to kick the old version out of memory completely other than rebooting?
LuigiThirty is offline  
Old 19 August 2017, 00:55   #7
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 582
Quote:
Originally Posted by LuigiThirty View Post
If I fix a bug in the library, is there a way to kick the old version out of memory completely other than rebooting?
It's been a while, so I'm not sure about this - but doesn't "avail flush" do just that, provided no applications currently have the library open?
robinsonb5 is offline  
Old 19 August 2017, 01:44   #8
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Quote:
Originally Posted by robinsonb5 View Post
It's been a while, so I'm not sure about this - but doesn't "avail flush" do just that, provided no applications currently have the library open?
Of course, when the application crashes it doesn't free the library. Scout can forcefully free it and then I can flush the cache through WB.
LuigiThirty is offline  
Old 19 August 2017, 05:39   #9
PeterK
Registered User
 
Join Date: Apr 2005
Location: Hangover
Posts: 2,407
Quote:
Originally Posted by LuigiThirty View Post
If I fix a bug in the library, is there a way to kick the old version out of memory completely other than rebooting?
Not sure what you really want to do, but you could call Forbid(), change lib_Node/ln_Name from "matrix.library" into something else like "old_matrix.library", then CacheClearU(), Permit() and load your new patched matrix.library. Of course, this is just some sort of bad coding.
PeterK is offline  
Old 19 August 2017, 07:09   #10
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Here's a question for you. I'm trying to calculate a rotation matrix but I think the compiler is screwing up my floating point format. I'm using the latest vbcc, optimization disabled.

Code:
VOID GetXRotationMatrixForOrientation( register __a0 Orientation *o, register __a1 Matrix44 *destination )
{
	FLOAT rad = degreesToRadians(o->rotation.x);
	IdentityMatrix44(destination);
	
	destination->data[1][1] = IEEESPCos(rad);
	destination->data[1][2] = IEEESPSin(rad);
	destination->data[2][1] = -IEEESPSin(rad);
	destination->data[2][2] = IEEESPCos(rad);
}
I debugged this and found that the calculated value for rad is correct along with the retrieved o->rotation.x. The generated code for the first call to IEEESPCos though is:

Code:
_GetXRotationMatrixForOrientation
	sub.w	#16,a7
	movem.l	l42,-(a7)
	move.l	a0,a3
	move.l	a1,a2
	move.l	(12,a3),d0
	jsr	_degreesToRadians
	move.l	d0,d1
	move.l	d1,d2
	move.l	a2,a0
	jsr	_IdentityMatrix44
	move.l	d2,-(a7)
	jsr	__ieees2d ;<-- ?
	movem.l	d0/d1,-(a7)
	jsr	_IEEESPCos
If I'm reading it correctly is converting the argument to IEEESPCos to a double-precision value when the function takes a single-precision value. That's weird. Is there something I'm missing that's causing it to use double-precision? I'd rather not hand-write these routines in ASM if I don't have to. All struct values are FLOAT type which according to the headers is a 32-bit long, not a 64-bit value.

edit: A new vbcc was just released this week actually! I upgraded to it and now the generated calls are all given single-precision operands. The numbers I'm getting back at least make sense now! Still need to do some debugging to figure out why they're not right though.

Last edited by LuigiThirty; 19 August 2017 at 10:22.
LuigiThirty is offline  
Old 21 August 2017, 23:30   #11
LuigiThirty
Registered User

 
Join Date: Dec 2016
Location: USA
Posts: 99
Hey, I got it working! Other than an FOV issue (it's extremely fisheye) and no clipping so if a line goes out of the screen coordinates it trashes chipmem.

https://twitter.com/LuigiThirty/stat...28868772380673

LuigiThirty 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
Shared configuration Anubis support.FS-UAE 2 26 April 2016 00:51
Closing a window with shared Messageport? AGS Coders. System 0 18 March 2015 16:05
HELP: Opus5, KingCON, SysInfo.library (Sysmon.library) triangle Michael support.Apps 6 10 March 2014 15:08
How do i Get Miami to mount shared folders Rogueraven support.Hardware 6 13 March 2008 12:57
Making a shared library from a gcc .a library JoJo Coders. General 1 10 March 2003 20:06

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 14:29.


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