On 2026/11/05 00:17, Eric Botcazou wrote:
>> I've just read the manual, and I think import library is still needed here.
> 
> Then you need to read it again!
> 
>> According to the manual, directly link to DLL is possible, but usually not
>> easy to use under Cygwin/MSYS2, because:
>>
>> 1. GCC only adds -L<path>/lib by default, while DLLs are usually placed
>> under <path>/bin, so you have to manually add a -L for this.
> 
> But that's not true for libgnat/libgnarl, see the install tree.

I understand that gnatmake and some other Ada tools will automatically do this,
but I think it might be better to still provide a import lib, so that you can
link to shared libgnat just like other libraries, e.g. libgcc. For example,
what if you have a project with mixed Ada/C/C++, and you want to use the C-style
way to build/link it?

There's also following snippet from gcc/ada/gnat_ugn.texi, line 17357

$@{LIB_DIR@}:
    mkdir -p $@{dir $@@ @}
    cd $@{dir $@@ @} && gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} 
-lgnat
    cd $@{dir $@@ @} && cp -f ../*.ali .

> 
>> 2. DLLs are usually versioned, so you can't use -lfoo, but have to use, e.g.
>> -lfoo-17
> 
> That's automatically done by gnatmake and we need to keep the version number 
> because there is no stable ABI for these libraries.

That's OK if you want that, I'm not familiar with Ada. But I'd like to note that
on Linux, there's a libgnat.so -> libgnat-<version>.so symlink installed, so
-lgnat can work on Linux, and it might be suprising if it can't work on Windows.
> 
>> Regarding 2, I think we can slightly edit the original patch and remove
>> $(LIBRARY_VERSION) from import lib, so that we got libgnat.dll.a instead of
>> libgnat-17.dll.a, and users can easily link with -lgnat.
> 
>> Below is a fixup patch.
> 
> No, we definitely do not want that.
> 

Reply via email to