English Amiga Board


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

 
 
Thread Tools
Old 19 June 2018, 11:11   #1
NoBrain2k
Registered User

 
Join Date: Jun 2018
Location: UK
Posts: 4
Using libraries with VBCC (Undefined Symbol)

Hi all

Despite years of (very on and off) programming in C this particular issue is alluding me. I would like to use either ptreplay or medplayer in my little C project, however I get complaints that symbols such as __LoadModule() aren't defined when linking. This is the case with both ptreplay and medplayer. It makes sense that the linker would complain about this, but I'm flummoxed as to the solution.

For the avoidance of doubt, I have of course included the proto .h files as required. I have tried passing the .library file to the linker but it complains that it is already a binary file (again, makes sense). I can not find any .lib files for ptreplay or medplayer.

Any suggestions?
NoBrain2k is offline  
Old 19 June 2018, 11:22   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 818
.library files are amiga os libraries, which you need to open using the os openlibrary operation(s).

Some libraries have stubs you can link in, that automatically open/close the amiga library in question and forward the calls to them, but I don't know if the ones you mention have such stubs also.
hooverphonique is offline  
Old 19 June 2018, 11:40   #3
NoBrain2k
Registered User

 
Join Date: Jun 2018
Location: UK
Posts: 4
Thanks hooverphonique.


I understand that .library files are for Amiga OS. When I was trying to use it with the linker I was, admittedly, clutching at straws. OpenLibrary for (for example) medplayer.library appears to work perfectly in my compiled binary. I just can't generate a compiled binary that uses any of the library's own functions because the linker complains that I'm using functions that don't exist.
NoBrain2k is offline  
Old 19 June 2018, 12:05   #4
nogginthenog
Amigan

 
Join Date: Feb 2012
Location: London
Posts: 677
The proto include will normally include an 'inline' include that contains inline assembly that loads libbase into a6 and calls the function.

If you're getting references to unknown functions then this is not working.

These headers are compiler specific. You cannot use GCC or SASC headers with VBCC.
There are tools to generate these headers from the FD files provided by library authors.
nogginthenog is offline  
Old 19 June 2018, 12:15   #5
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 818
yes, so in order to invoke e.g. __LoadModule() like any other C function, it would need a stub that forwards that call to the correct library vector, but it sort of sounds like your proto files only declare those stubs, not define them, thus the linker can't locate their implementation.
hooverphonique is offline  
Old 19 June 2018, 12:16   #6
NoBrain2k
Registered User

 
Join Date: Jun 2018
Location: UK
Posts: 4
Quote:
Originally Posted by nogginthenog View Post
These headers are compiler specific. You cannot use GCC or SASC headers with VBCC.
There are tools to generate these headers from the FD files provided by library authors.

THIS is probably the thing I am missing. I have noticed the FD files whilst I was head-scratching but didn't know what they were for. A quick Google indicates that there is a fd2pragma tool included with VBCC.


I'll have a play tonight and see what I can do.


Thanks very much both of you.

Last edited by NoBrain2k; 19 June 2018 at 12:17. Reason: Thanking both
NoBrain2k is offline  
Old 21 June 2018, 18:10   #7
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,222
You need the FD file and the clib prototypes header. Assuming the library is xyz.library, generate the (portable) proto/xyz.h like this:
Code:
fd2pragma special 38 to include/proto xyz.fd
Then generate the assembler inlines (inline/xyz_protos.h):
Code:
fd2pragma special 70 voidbase to include/inline xyz.fd clib clib/xyz_protos.h
You will still be missing the stubs library, but usually the inlines are prefered anyway.
phx is offline  
Old 03 July 2018, 13:02   #8
NoBrain2k
Registered User

 
Join Date: Jun 2018
Location: UK
Posts: 4
Quote:
Originally Posted by phx View Post
You need the FD file and the clib prototypes header. Assuming the library is xyz.library, generate the (portable) proto/xyz.h like this:
Code:
fd2pragma special 38 to include/proto xyz.fd
Then generate the assembler inlines (inline/xyz_protos.h):
Code:
fd2pragma special 70 voidbase to include/inline xyz.fd clib clib/xyz_protos.h
You will still be missing the stubs library, but usually the inlines are prefered anyway.

Thanks very much, after a bit of trial and error I finally managed to get this to work. I did actually switch to GCC because I was struggling a bit (and I always wanted to use GCC in linux anyway) but the process was much the same, with different 'special' numbers
NoBrain2k 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
vasm "undefined symbol" is driving me nuts jotd Coders. Asm / Hardware 6 03 December 2017 21:17
Reference to undefined symbol __ldivu / __lmodu iliak Coders. C/C++ 8 25 July 2016 01:01
unresolved symbol __ieeefixdsl (vbcc) meynaf Coders. C/C++ 19 19 June 2016 17:32
AsmOne: Undefined symbol copse Coders. Asm / Hardware 2 02 April 2012 02:41
Undefined symbol bsr.b init_bitmaps VoltureX Coders. General 12 13 November 2011 17:11

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 20:48.


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