comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Linking with GNAT on Windows
Date: Tue, 24 Nov 2009 18:34:43 +0100
Date: 2009-11-24T18:34:40+01:00	[thread overview]
Message-ID: <69epr50o3g3w$.108hd37jl3fjj$.dlg@40tude.net> (raw)
In-Reply-To: 0ac0e003-176f-48d1-b72f-56f81dae922e@1g2000vbm.googlegroups.com

On Tue, 24 Nov 2009 08:26:00 -0800 (PST), Maciej Sobczak wrote:

> Imagine a C library compiled with Visual Studio. This library is used
> by an Ada program by means of pragma Import.
> 
> When the C library is compiled in the Debug mode, GNAT can link the
> whole program. If the same C library is compiled in the Release mode,
> the GNAT linker says "undefined reference" with regard to the C
> function that is imported by Ada.

Hmm, it is no matter how the program is compiled, but how is it linked.
Debug/Release are just project scenario names, which can mean anything in
the concrete project.

Of course we cannot exclude that some inspired C programmer could make use
of #ifdef __DEBUG__ to change names of all functions in the source...

AFAIK, GNAT does not recognize the MS lib files, so you have to convert
them into *.a with the corresponding mangling of names especially if that
is C++ and not export "C" stuff.

There is also exist *.def files which may influence the names of the
entries in the import library.

Further there exist __declspec(dllexport), __cdecl, __stdcall modifiers in
the program, which might have effect on the external names.

Plus in Visual Studio there can be defined post build steps. which might
call scripts and do, well, anything.

All in one, it is impossible to say what is going on. You have to verify
all steps. I would ensure that *.a file is created and used by GNAT. Then I
would check the names in it (nm -s). Then I would verify the content of its
source *.lib file etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2009-11-24 17:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-24 16:26 Linking with GNAT on Windows Maciej Sobczak
2009-11-24 17:34 ` Dmitry A. Kazakov [this message]
2009-11-24 18:03   ` Pascal Obry
2009-11-25  1:36     ` Kevin K
2009-11-25  8:43   ` Maciej Sobczak
2009-11-25  9:46     ` Dmitry A. Kazakov
2009-11-25 12:47       ` Maciej Sobczak
2009-11-25 13:44         ` Dmitry A. Kazakov
replies disabled

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