From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,93f13c4bf2e19e49 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-21 19:01:05 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc2.on.home.com.POSTED!not-for-mail Message-ID: <3B831260.D44E682B@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Calling Custom C Functions From Ada References: <8e205e9b.0108211257.4c56b7d9@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 22 Aug 2001 02:01:05 GMT NNTP-Posting-Host: 24.141.193.224 X-Complaints-To: abuse@home.net X-Trace: news1.rdc2.on.home.com 998445665 24.141.193.224 (Tue, 21 Aug 2001 19:01:05 PDT) NNTP-Posting-Date: Tue, 21 Aug 2001 19:01:05 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:12203 Date: 2001-08-22T02:01:05+00:00 List-Id: Brant wrote: > I'm trying to call a custom C function from an Ada program. I've set > my Ada program up using the INTERFACE pragma, but I can't seem to get > the linker to locate the associated C object code. > > I've written and built my C functions using Microsoft Visual C++; I've > tried both static and dynamic libraries, so I get the *.lib, *.obj > files along with a *.exp file. I'm using a DDC-I DACS Ada compiler > under Windows NT. > > When I link my Ada code, which one of the generated C files do I need > to reference? No matter which I choose I get an "adalink: undefined > reference to `MyFunction'" error, which is the same error I get when I > don't even point to a file. Do I need to do some tweaking of the C > files? Do I need to reference the specific function (as opposed to > just a file) when I link? If you've not already done so, make sure you compile your C function with extern "C" linkage. Otherwise the function name get's mangled according to C++ mangling conventions: extern "C" int my_function(void); or : extern "C" { int my_function(void); } -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg