Re: Linking with GNAT on Windows



On 24 Lis, 18:34, "Dmitry A. Kazakov" <mail...@xxxxxxxxxxxxxxxxx>
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
.



Relevant Pages

  • Re: Newbie question: How to use gnat make
    ... I want to build a program using the GNAT GPL compiler on ... is it similar in Ada? ... You cannot place multiple compilation units in the same file. ... The only compilation unit that you name on the command ...
    (comp.lang.ada)
  • Re: GNATs stack checking in Ubuntu 9.04 (and Shootout regex-dna)
    ... Another way of using modified copies of GNAT library ... Compile without the -a switch: ... Running time of ./regexdna: 63 seconds. ... compilation near instanteous; I suppose it is ...
    (comp.lang.ada)
  • Debug Question
    ... modify the debug attribute of the compilation element in the ... The first method is working fine -- but it turns detailed debugging on ... Note that this second technique will cause all files within a given ... application to be compiled in debug mode. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Detecting debug mode
    ... Michael Archon Sequoia Nielsen wrote: ... compilation the preprocessor checks whether this symbol is defined. ... However, I think I need dbstack to detect that I'm actually in debug mode. ...
    (comp.soft-sys.matlab)
  • Re: Compilation error with GNAT
    ... > Start with the basic GNAT complilation model. ... > GNAT is treating spec/body alternativly spec if the spec does'nt requrie ... Ada compilation model, which is explained in detail in the Ada ...
    (comp.lang.ada)