comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Linking with GNAT on Windows
Date: Wed, 25 Nov 2009 00:43:11 -0800 (PST)
Date: 2009-11-25T00:43:11-08:00	[thread overview]
Message-ID: <3ade5d53-eedd-4a0e-bf4f-bbf6a62cf997@c3g2000yqd.googlegroups.com> (raw)
In-Reply-To: 69epr50o3g3w$.108hd37jl3fjj$.dlg@40tude.net

On 24 Lis, 18:34, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> Hmm, it is no matter how the program is compiled, but how is it linked.

The GNAT invocation is the same in both cases and includes this:

-largs -lmylibrary

with mylibrary.lib (the result of compilation on Visual Studio) file
somewhere around.

> Of course we cannot exclude that some inspired C programmer

I was that programmer. The whole C library amounts to a single
function with single line of code ("Hello from C", essentially), no
preprocessor and no other tricks. The function is declared as extern
"C" to avoid name mangling.

> AFAIK, GNAT does not recognize the MS lib files,

It seems to recognize them. Not only it complains when the file is not
around (note: it can automatically make an association between -
lmylibrary linker option and the mylibrary.lib file - this would not
be the case if .lib files were not supported at all), but it really
works fine if the C library is build in the Debug mode.
I have tried to analyze all options in these two modes, but do not see
any differences that would affect this.

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

Yes, but this is not used. My naive first diagnostics was that the
library compiled in Debug mode has its names exported by default,
whereas the Release mode would need the .def file. This theory is
contradicted by the fact that a test C program can use that library no
matter how it was compiled. But then, it is the single toolchain on
the whole path.

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

None of these are used. Note that it is a static library, not a DLL.

> Plus in Visual Studio there can be defined post build steps.

These are not defined. The C library was created as a pristine
project.

> All in one, it is impossible to say what is going on.

Cool.
I am pretty convinced that this is not even a GNAT issue, but rather
concerns the interaction of Visual Studio and MinGW toolchain that is
a backend for GNAT.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



  parent reply	other threads:[~2009-11-25  8:43 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
2009-11-24 18:03   ` Pascal Obry
2009-11-25  1:36     ` Kevin K
2009-11-25  8:43   ` Maciej Sobczak [this message]
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