dgrimmer@ciss.Dayton.NCR.COM (Dave.Grimmer@Dayton.NCR.COM) (12/17/90)
I am using Clipper 87 and MS C 5.10 to try to do some trig functions.
The programs and command lines used to link them are shown below.
Basically, the problem is that I get an unresolved external refference
to "_cos" in a program that try to do a cosine function. I probably
have missed something simple. If you have any experience interfacing
Clipper and MS C, please look at this simple problem and let me know
what I have missed. Any help would be appreciated...
--
Dave Grimmer NCR Corporate Information Resource Planning (PCD 6)
Dave.Grimmer@Dayton.NCR.COM
TEST.PRG
--------
clear
? "The cos of 30 degrees is: "+str(djgcos(30))
DJGCOS.C
--------
/* Return cos of angle passed in degrees */
#include <extend.h>
#include <nandef.h>
#include <math.h>
CLIPPER djgcos()
{
double i;
i=_parnd(1);
_retnd(cos(i / 57.29578));
}
COMPILE CLIPPER PROGRAM WITH:
-----------------------------
clipper test -m
COMPILE MS C 5.10 PROGRAM WITH:
-------------------------------
CL -c -AL -Zl /Oalt /FPa /Gs djgcos.c
LINK WITH MS LINK 3.65
----------------------
link /NOE test.obj djgcos.obj ,,, \clipper\clipper
RESULTS:
-------
LINK : error L2029: Unresolved externals:
_cos in file(s):
DJGCOS.OBJ(djgcos.c)
There was 1 error detected
--
Dave Grimmer NCR Corporate Information Resource Planning (PCD 6)
Dave.Grimmer@Dayton.NCR.COM
mpd@anomaly.sbs.com (Michael P. Deignan) (12/24/90)
dgrimmer@ciss.Dayton.NCR.COM (Dave.Grimmer@Dayton.NCR.COM) writes: >RESULTS: >------- >LINK : error L2029: Unresolved externals: >_cos in file(s): > DJGCOS.OBJ(djgcos.c) The solution is to link in llibc[ea].lib, or whatever appropiate Microsoft C library you use. COS() is a C function in the MSC library. You didn't specify the library in the LINK, thus, it can't find the function. Hence, unresolved external. MD -- -- Michael P. Deignan, President -- Small Business Systems, Inc. -- -- Domain: mpd@anomaly.sbs.com -- Box 17220, Esmond, RI 02917 -- -- UUCP: ...uunet!rayssd!anomaly!mpd -- Telebit: +1 401 455 0347 -- -- XENIX Archives: login: xxcp, password: xenix Index: ~/SOFTLIST --
catfood@NCoast.ORG (Mark W. Schumann) (12/24/90)
dgrimmer@ciss.Dayton.NCR.COM (Dave.Grimmer@Dayton.NCR.COM) writes: >I am using Clipper 87 and MS C 5.10 to try to do some trig functions. >The programs and command lines used to link them are shown below. >Basically, the problem is that I get an unresolved external refference >to "_cos" in a program that try to do a cosine function. I probably >have missed something simple. If you have any experience interfacing >Clipper and MS C, please look at this simple problem and let me know >what I have missed. Any help would be appreciated... >CLIPPER djgcos() >{ > double i; > i=_parnd(1); > _retnd(cos(i / 57.29578)); >} >LINK WITH MS LINK 3.65 >---------------------- >link /NOE test.obj djgcos.obj ,,, \clipper\clipper >RESULTS: >------- >LINK : error L2029: Unresolved externals: >_cos in file(s): > DJGCOS.OBJ(djgcos.c) Your C function simply does some setup and calls the function named cos() that should be in one of the Microsoft C libraries. But you're only linking in CLIPPER.LIB. (By the way, most C compilers stick a leading underscore in front of function names; this doesn't have a whole lot to do with your problem.) Try linking in whatever MSC library contains cos(). That might give you a different linker error because cos() itself may call functions that are assumed to be in the MSC startup code. In that case you might want to go really crazy and tinker with the startup code or write your own cos(). In general, it is not as easy as it looks to interface C and Clipper when your C requires the use of library functions. I hope this helps a little. -- ============================================================ Mark W. Schumann 3111 Mapledale Avenue, Cleveland 44109 USA Domain: catfood@ncoast.org UUCP: ...!mailrus!usenet.ins.cwru.edu!ncoast!catfood