When trying to compile the following source code:

#include <random> #include <iostream> int main(){ std::tr1::random_device rd; std::tr1::mt19937 rng(rd()); std::tr1::uniform_int<int> uni(0,20); std::cout<<uni(rng)<<std::endl; } 

bcc32.exe t.cpp I get this error:

 Turbo Incremental Link 6.51 Copyright (c) 1997-2013 Embarcadero Technologies, Inc. Error: Unresolved external 'std::tr1::_Random_device()' referenced from <...>\T.OBJ Error: Unable to perform link 

Compiler version 6.70.4983.33517 of RAD Studio XE5

How to fix this error? Maybe you need to connect some kind of library?

  • Does it compile at all? ... std::tr1::mt19937 rng(rd); - this? It seems to be necessary std::tr1::mt19937 rng(rd()); . And also - what, Borland still keeps it all in tr1 , not just in std ? If you delete ::tr1 , what do you get? - Harry
  • @Harry Yes, there should be rd() , I'll fix it now. But the error remains, of course. Without tr1 will be something like Error E2316 t.cpp 5: 'random_device' is not a member of 'std' in function main() - Im ieee

0