digitalmars.D - ldc2 linux -> windows cross-compile linker error
- H. S. Teoh (32/32) Jul 25 I cross-compile one of my projects from Linux to Windows, and it was
- Richard (Rikki) Andrew Cattermole (1/1) Jul 25 Did you try renaming the import library to match the case sensitivity?
- H. S. Teoh (13/14) Jul 25 Huh, I added a symlink in lib/mingw: Bcrypt.lib -> bcrypt.lib, and now
- kinke (3/11) Jul 26 I'm pretty sure this is caused by
- H. S. Teoh (6/18) Jul 26 Aha! That's where the capital B Bcrypt comes from. Is there any reason
- 0xEAB (3/6) Jul 26 Microsoft documents the lib file as `Bcrypt.lib`; see
- 0xEAB (4/6) Jul 26 Anyway, that line ought to be irrelevant for the most part and
- 0xEAB (4/6) Jul 26 Anyway, the code in question has been replaced by the upcoming
- H. S. Teoh (7/12) Jul 26 OK, in that case the file in the tarball should be named 'Bcrypt.lib'
- kinke (3/6) Jul 27 The 'convention' is to use lowercase for the Windows libs, as in
- H. S. Teoh (6/13) Jul 27 Well, I don't really care which way it is, as long as it's consistent
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
Did you try renaming the import library to match the case sensitivity?
Jul 25
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
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
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: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√e980Strange 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.]
Jul 26
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
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
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
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: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 LincolnAha! 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
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
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: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. KnuthOK, 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