English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 08 September 2009, 01:48   #1
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,750
Trying to use a shared library in StromC V4 (default gcc compiler)

Hiya,

I thought this would be easy but of course it's not

I'm trying to use someone else's sound library in my C++ project, I don't know much about this library but I do have the original source code (SAS/C) that used it plus (I think) the assembler source code of the library itself

I was hoping it would be as easy as adding the library to my project's list of libraries in Storm C and then adding the library's header file but this just results in Storm C giving me a linker error saying that the library is already linked

The original code used the following method of loading the library
Code:
DoomSndBase = OpenLibrary ("doomsound.library",37)
And the following header file declartion
Code:
 
extern void Sfx_SetVol (int vol);
#pragma libcall DoomSndBase Sfx_SetVol 1e 001
If I try to copy this in my project (without adding the library through the IDE) it also refuses to link because the linker cannot find the objects to go with these method declarations...even though they are marked as 'external'

Now I've read that this weird Pragma calls are compiler specific...is this the cause of my angst? If so, how do determine the correct ones for the version of GCC that I'm using?

Last edited by NovaCoder; 09 September 2009 at 01:37.
NovaCoder is offline  
Old 08 September 2009, 04:38   #2
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,750
After looking at a StormC shared library example it looks like you need to include an assembler file representation of the library you are trying to link to. This seems more than a little odd to me, why do you need to do this?

In the example they refer to it as an assembler 'stub' but to me it looks like it contains the actual implementation, is that correct?

stubs.asm
Code:
 
XREF _TestBase
XDEF _AddTwo
XDEF _AddThree
 
_AddTwo
move.l 4(sp),d0
move.l 8(sp),d1
move.l a6,-(sp)
move.l _TestBase,a6
jsr -30(a6)
move.l (sp)+,a6
rts
_AddThree
movem.l a6/d2,-(sp)
move.l 12(sp),d0
move.l 16(sp),d1
move.l 20(sp),d2
move.l _TestBase,a6
jsr -36(a6)
movem.l (sp)+,a6/d2
rts
And the actual library's scource code implementation looks like this
Code:
#pragma libbase LibBase
 
int AddTwo(__REGD0(int a), __REGD1(int b), __REGA6(struct LibBase *base))
{
return base->last_result = a + b;
}
 
int AddThree(__REGD0(int a), __REGD1(int b), __REGD2(int c), __REGA6(struct LibBase *base))
{
return base->last_result = a + b + c;
}

Last edited by NovaCoder; 08 September 2009 at 07:41.
NovaCoder is offline  
Old 08 September 2009, 11:46   #3
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,750
Well it appears that this is just an ASM Stub so the question is how to I generate a STUB for the library that I want to link to in my STORM project?
NovaCoder is offline  
Old 09 September 2009, 01:38   #4
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,750
I've just been told (thanks Sam Crow) that FD2Pragma is used to generate the assembler STUB.
NovaCoder 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
GCC and ixemul.library Rixa Coders. Language 24 10 November 2016 23:18
Pascal compiler bx20 support.Apps 10 20 August 2010 13:45
C compiler raptor_13 Coders. General 14 27 May 2008 09:40
latest GCC compiler 68k Tony Landais Coders. General 27 23 November 2006 01:02
Making a shared library from a gcc .a library JoJo Coders. General 1 10 March 2003 19: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 18:32.


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