问题
I am trying to generate random numbers using std::random_device
but each time I run the program they are the same. I tried the same code using an online IDE and it ran as expected. According to an answer here, this is a bug in Cygwin and MSYS2.
How can I upgrade MSYS2? I tried running the commands pacman -Syu
and pacman -Su
in its terminal but it had errors:
MSYS ~ $ pacman -Syuu error: mingw32: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: mingw64: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: msys: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04"
is unknown error: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" could
not be looked up remotely :: Synchronizing package databases...
mingw32 472.5 KiB 305K/s 00:02
[#####################] 100% mingw32.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: mingw32: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update mingw32 (invalid or corrupted
database (PGP signature)) mingw64 475.0 KiB 346K/s
00:01 [#####################] 100% mingw64.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: mingw64: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update mingw64 (invalid or corrupted
database (PGP signature)) msys 189.8 KiB 164K/s
00:01 [#####################] 100% msys.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: msys: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update msys (invalid or corrupted database
(PGP signature)) error: failed to synchronize all databases
Is there any alternatives or work around for generating random numbers on Windows?
回答1:
I got it to work by referring to this news page on MSYS2. I had to run pacman -Sydd pacman
before the rest of the steps could work.
来源:https://stackoverflow.com/questions/63201980/why-are-the-random-numbers-all-the-same-with-msys2