Skip to content

Windows link error with std.random.uniform() in v2.111 #10731

Description

@Superbelko

I having link errors now in code that previously working fine, the error is as follows

Error: undefined reference to `BCryptGenRandom`
       referenced from `nothrow @nogc @trusted bool std.random.bcryptGenRandom!(ulong).bcryptGenRandom(out ulong)`
       perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`

It works if I link bcrypt.lib manually (using dub libs section).

Looking at the source code for std.random reveals that there is pragma(lib, "Bcrypt.lib"); but for some reason it doesn't works.

Test code

import std.random;

enum variance = 5.0f;

void main() {
    const foo = uniform!"[]"(-variance, variance);
}

Activity

  1. added
    Severity:Regression
    OS:Windows
    on Apr 4, 2025
  2. 0xEAB commented on Apr 4, 2025

    @0xEAB
    Member

    Do we want to link Phobos against bcrypt?
    Or do we load it and potentially risk another #10629?

  3. added 3 commits that reference this issue on Apr 4, 2025
    d821e66
    ffdde76
    f53f976
  4. added a commit that references this issue on Apr 4, 2025
    bb54a2f
  5. added a commit that references this issue on Apr 4, 2025
    8074ec8
  6. 0xEAB commented on Apr 4, 2025

    @0xEAB
    Member

    Thanks for the report :)
    This has been fixed on ~stable, it’s therefore scheduled for v2.111.1.

  7. added a commit that references this issue on Apr 11, 2025
    e4f75bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS:WindowsSeverity:Regression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions