[comp.sys.amiga.tech] SAS/C 5.10 and amiga.lib - Help!

gordon@sugar.hackercorp.com (Gordon Neissen) (10/03/90)

I am trying to write some routines in C to be called from basic and
am having problems with compiling a few small tests.  The only example 
I have to work with is as follows:
 
/* add.c */
void main( Result, x, y )
short *Result, x, y;
{
    *Result = x + y;
}
 
And this works compiled with SAS/C 5.10 using the commands:
    lc -v add
    blink add.o to add LIB amiga.lib, lc.lib
 
But when I tried to change it to work with float it fails to link.  I get 
an error: "unable to find library amiga.lib".  I get the same thing when 
trying to play with strings.

-- 
| Gordon Niessen                |  My opinions are none of your business.   |
| gordon@sugar.hackercorp.com   |  "Never underestimate a users stupidity"  |
 \-------------------------------------------------------------------------/

johnhlee@fulla.cs.cornell.edu (John H. Lee) (10/04/90)

In article <6697@sugar.hackercorp.com> gordon@sugar.hackercorp.com (Gordon Neissen) writes:
[...program deleted...]
>And this works compiled with SAS/C 5.10 using the commands:
>    lc -v add
>    blink add.o to add LIB amiga.lib, lc.lib
                            ^^^^^^^^^  ^^^^^^
> 
>But when I tried to change it to work with float it fails to link.  I get 
>an error: "unable to find library amiga.lib".  I get the same thing when 
>trying to play with strings.

Two things:
    1)  amiga.lib must follow lc.lib (i.e., LIB lc.lib, amiga.lib)
    2)  If you use floats, you must also link with a math library, for
	instance, lcm.lib.  This must precede lc.lib (i.e., LIB lcm.lib,
	lc.lib, amiga.lib).

The error arises because lc.lib depends on amiga.lib and blink searches
the libraries in the order you specify.

-------------------------------------------------------------------------------
The DiskDoctor threatens the crew!  Next time on AmigaDos: The Next Generation.
	John Lee		Internet: johnhlee@cs.cornell.edu
The above opinions of those of the user, and not of this machine.

joseph@valnet.UUCP (Joseph P. Hillenburg) (10/05/90)

How DO you call C routines from BASIC?

-Joseph Hillenburg

UUCP: ...iuvax!valnet!joseph
ARPA: valnet!joseph@iuvax.cs.indiana.edu
INET: joseph@valnet.UUCP

peterk@cbmger.UUCP (Peter Kittel GERMANY) (10/08/90)

In article <eDkJq11w163w@valnet> joseph@valnet.UUCP (Joseph P. Hillenburg) writes:
>How DO you call C routines from BASIC?

If you mean functions that are part of a normal Amiga runtime library,
then you just need to build a .bmap file and use the same mechanism as
for other system function calls. (Look at the manual and into the prog
basicdemos/ConvertFD for details of building a .bmap file.)

But I'm afraid you speak about amiga.lib which is a link library.
I see no easy way to access this. Hard way would be, take SAS/C 5.10,
use library creation feature, make up functions for every function
you want to include from amiga.lib, compile this to a library and
procede like above. (Has anybody done this already?) I can't guess
about timing penalties of such procedure.

-- 
Best regards, Dr. Peter Kittel  // E-Mail to  \\  Only my personal opinions... 
Commodore Frankfurt, Germany  \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk