On Friday, 25 July 2025 at 07:16:55 UTC, evilrat wrote:
On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote:
From "Programming in D" book:

import std.stdio;
import std.random;

    void main() {
        int number = uniform(1, 101);

        writeln("Edit source/app.d to start your project.");
    }

    Running it generates:
phobos64.lib(random_6ea_855.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function _D3std6random__T15bcryptGenRandomTmZQuFNbNiNeJmZb C:\Users\broth\AppData\Local\Temp\.rdmd\rdmd-app.d-99D1A2446E2CA5089AD8A9B31EA74F07\app.exe.tmp : fatal error LNK1120: 1 unresolved externals
    Error: linker exited with status 1120
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64\link.exe /NOLOGO "C:\Users\broth\AppData\Local\Temp\.rdmd\rdmd-app.d-99D1A2446E2CA5089AD8A9B31EA74F07\objs\app.exe.obj" /OUT:"C:\Users\broth\AppData\Local\Temp\.rdmd\rdmd-app.d-99D1A2446E2CA5089AD8A9B31EA74F07\app.exe.tmp" /DEFAULTLIB:phobos64 /LIBPATH:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\lib\x64" legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.26100.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.26100.0\um\x64"
    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, ...)`

* The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command & 'rdmd' 'c:\dev\D\21 - 30\c27_a_do_while_loop\source\app.d'" terminated with exit code: 1.

Is there another way to get a random integer between 1 and 100?

could be this:
Windows link error with std.random.uniform() in v2.111 #10731
https://github.com/dlang/phobos/issues/10731

Regarding https://github.com/dlang/phobos/issues/10731
DMD Version v2.111.1 will fix this, but hasn't been published yet.

Reply via email to