comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Re: Calling Custom C Functions From Ada
Date: Wed, 22 Aug 2001 02:01:05 GMT
Date: 2001-08-22T02:01:05+00:00	[thread overview]
Message-ID: <3B831260.D44E682B@home.com> (raw)
In-Reply-To: 8e205e9b.0108211257.4c56b7d9@posting.google.com

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



  parent reply	other threads:[~2001-08-22  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-21 20:57 Calling Custom C Functions From Ada Brant
2001-08-21 21:22 ` Ted Dennison
2001-08-21 21:23 ` Larry Hazel
2001-08-22  2:01 ` Warren W. Gay VE3WWG [this message]
2001-08-22 16:45 ` Brant
  -- strict thread matches above, loose matches on Subject: below --
2001-08-21 22:17 Beard, Frank
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox