www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - ldc2 linux -> windows cross-compile linker error

reply "H. S. Teoh" <hsteoh qfbox.info> writes:
I cross-compile one of my projects from Linux to Windows, and it was
working fine with ldc2-1.40.1.  After upgrading to ldc2-1.41.0, however,
it's giving me this strange linker error:

```
lld-link: error: could not open 'Bcrypt.lib': No such file or directory
Error: linking with LLD failed
```

Compiler invocation:
```
ldc2 -mtriple=x86_64-windows-msvc -L/subsystem:windows -L/entry:wmainCRTStartup
-O -linkonce-templates $SOURCE_FILES
```

Relevant section in ldc2.conf:
```
"x86_64-.*-windows.msvc":
{
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
    ];
    lib-dirs = [
        "/usr/src/d/ldc/ldc2-1.41.0-windows-x64/lib",
    ];
};
```

The path /usr/src/d/ldc/ldc2-1.41.0-windows-x64/lib points to the lib
directory of the unpacked tarball of the windows version of LDC. I
notice that there's a file mingw/bcrypt.lib, but for whatever reason
it's not getting picked up.

What am I doing wrong?


T

-- 
Why did the chicken cross the Möbius strip?  To get to the same side!
Jul 25
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
Did you try renaming the import library to match the case sensitivity?
Jul 25
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Sat, Jul 26, 2025 at 05:19:52AM +1200, Richard (Rikki) Andrew Cattermole via
Digitalmars-d wrote:
 Did you try renaming the import library to match the case sensitivity?
Huh, I added a symlink in lib/mingw: Bcrypt.lib -> bcrypt.lib, and now everything works. Thanks! Strange thing, though: I tracked it down to a `pragma(lib, "Bcrypt");` in one of my modules. However, changing this line to use lowercase "bcrypt" does not make a difference. Running ldc2 -v indicates that for some reason it gets capitalized to Bcrypt.lib anyway by the compiler. But why is this? I checked other pragma(lib,...) declarations that had lowercase library names, and they don't get auto-capitalized. Why is bcrypt different? T -- The most powerful one-line C program: #include "/dev/tty" -- IOCCC
Jul 25
parent reply kinke <noone nowhere.com> writes:
On Friday, 25 July 2025 at 17:30:41 UTC, H. S. Teoh wrote:
 Strange thing, though: I tracked it down to a `pragma(lib, 
 "Bcrypt");` in one of my modules. However, changing this line 
 to use lowercase "bcrypt" does not make a difference.  Running 
 ldc2 -v indicates that for some reason it gets capitalized to 
 Bcrypt.lib anyway by the compiler. But why is this?  I checked 
 other pragma(lib,...) declarations that had lowercase library 
 names, and they don't get auto-capitalized. Why is bcrypt 
 different?
I'm pretty sure this is caused by https://github.com/dlang/phobos/blob/4fc3facb47241747d0919ab98501bcf7ea8c595e/std/internal/ indows/bcrypt.d#L9. [This module was added 3 months ago and is still in the stable branch only, not in master.]
Jul 26
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Sat, Jul 26, 2025 at 08:11:59AM +0000, kinke via Digitalmars-d wrote:
 On Friday, 25 July 2025 at 17:30:41 UTC, H. S. Teoh wrote:
 Strange thing, though: I tracked it down to a `pragma(lib, "Bcrypt");`
 in one of my modules. However, changing this line to use lowercase
 "bcrypt" does not make a difference.  Running ldc2 -v indicates that for
 some reason it gets capitalized to Bcrypt.lib anyway by the compiler.
 But why is this?  I checked other pragma(lib,...) declarations that had
 lowercase library names, and they don't get auto-capitalized. Why is
 bcrypt different?
I'm pretty sure this is caused by https://github.com/dlang/phobos/blob/4fc3facb47241747d0919ab98501bcf7ea8c595e/std/internal/windows/bcrypt.d#L9. [This module was added 3 months ago and is still in the stable branch only, not in master.]
Aha! That's where the capital B Bcrypt comes from. Is there any reason it's capitalized here but not in the actual library filename? T -- 128√e980
Jul 26
parent reply 0xEAB <desisma heidel.beer> writes:
On Saturday, 26 July 2025 at 15:38:52 UTC, H. S. Teoh wrote:
 Aha! That's where the capital B Bcrypt comes from.  Is there 
 any reason it's capitalized here but not in the actual library 
 filename?
Microsoft documents the lib file as `Bcrypt.lib`; see <https://learn.microsoft.com/en-us/windows/win32/api/Bcrypt/nf-bcrypt-bcryptgenrandom>.
Jul 26
next sibling parent 0xEAB <desisma heidel.beer> writes:
On Saturday, 26 July 2025 at 18:31:54 UTC, 0xEAB wrote:
 Microsoft documents the lib file as `Bcrypt.lib`; see 
 <https://learn.microsoft.com/en-us/windows/win32/api/Bcrypt/nf-bcrypt-bcryptgenrandom>.
Anyway, that line ought to be irrelevant for the most part and was only added because a sibling-module had something similar: <https://github.com/dlang/phobos/blob/4fc3facb47241747d0919ab98501bcf7ea8c595e/std/internal/windows/advapi32.d#L17>
Jul 26
prev sibling next sibling parent 0xEAB <desisma heidel.beer> writes:
On Saturday, 26 July 2025 at 18:31:54 UTC, 0xEAB wrote:
 Microsoft documents the lib file as `Bcrypt.lib`; see 
 <https://learn.microsoft.com/en-us/windows/win32/api/Bcrypt/nf-bcrypt-bcryptgenrandom>.
Anyway, the code in question has been replaced by the upcoming entropy system: <https://github.com/dlang/phobos/blob/3e50ddbf9fe342a650d9cf15995afb541b5a2c04/std/internal/entropy.d#L886>
Jul 26
prev sibling parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Sat, Jul 26, 2025 at 06:31:54PM +0000, 0xEAB via Digitalmars-d wrote:
 On Saturday, 26 July 2025 at 15:38:52 UTC, H. S. Teoh wrote:
 Aha! That's where the capital B Bcrypt comes from.  Is there any reason
 it's capitalized here but not in the actual library filename?
Microsoft documents the lib file as `Bcrypt.lib`; see <https://learn.microsoft.com/en-us/windows/win32/api/Bcrypt/nf-bcrypt-bcryptgenrandom>.
OK, in that case the file in the tarball should be named 'Bcrypt.lib' rather than 'bcrypt.lib', otherwise it breaks the linker on case-sensitive systems. T -- Nearly all men can stand adversity, but if you want to test a man's character, give him power. -- Abraham Lincoln
Jul 26
parent reply kinke <noone nowhere.com> writes:
On Saturday, 26 July 2025 at 18:58:33 UTC, H. S. Teoh wrote:
 OK, in that case the file in the tarball should be named 
 'Bcrypt.lib' rather than 'bcrypt.lib', otherwise it breaks the 
 linker on case-sensitive systems.
The 'convention' is to use lowercase for the Windows libs, as in https://github.com/dlang/dmd/blob/941545f298c6f081577568f32a4905aa40571d29/druntime/src/core/sys/windows/bcrypt.d#L13.
Jul 27
parent "H. S. Teoh" <hsteoh qfbox.info> writes:
On Sun, Jul 27, 2025 at 09:08:44AM +0000, kinke via Digitalmars-d wrote:
 On Saturday, 26 July 2025 at 18:58:33 UTC, H. S. Teoh wrote:
 OK, in that case the file in the tarball should be named
 'Bcrypt.lib' rather than 'bcrypt.lib', otherwise it breaks the
 linker on case-sensitive systems.
The 'convention' is to use lowercase for the Windows libs, as in https://github.com/dlang/dmd/blob/941545f298c6f081577568f32a4905aa40571d29/druntime/src/core/sys/windows/bcrypt.d#L13.
Well, I don't really care which way it is, as long as it's consistent and doesn't break on case-sensitive systems. :-) T -- People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth
Jul 27