Quantum Random Bit Generator

This is a discussion on Quantum Random Bit Generator within the C++ Programming forums, part of the General Programming Boards category; The whole point of #pragma is for the compiler to ignore But then multiple inclusion is possible?...

  1. #16
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    The whole point of #pragma is for the compiler to ignore
    But then multiple inclusion is possible?

  2. #17
    Registered User
    Join Date
    May 2008
    Posts
    81
    Quote Originally Posted by MarkZWEERS View Post
    What I don't get, is that if you truly want a random number, you should be connected to the device? Otherwise it's really pseudo-random.. that's what the QRBG class is mainly about: it's (I think) the communication interface between the device and your computer.
    the way it works is that the device is perpetually on and keeps spitting out random numbers to a buffer. then users can use the cpps or dlls to download data from that buffer.

    ok, i'll try running this on MS VC++ exp. hope that works. will post my results.

    was anyone else able to get it to work?

  3. #18
    Registered User
    Join Date
    May 2008
    Posts
    81
    ok i downloaded and installed MS VC++ express. Now, how the heck do I compile/run my cpp? There is no compile/run option in the damn thing (trust MS to build an evil app). In the words of Dilbert, "GAAAAAA!"

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Create a project. Unless you are making a windows application, you want a console application. The project should be a Win32 Console Application. I believe it is still called that in VC++ 2008. Be careful, there are other similar ones that use .NET and you don't want that.

    In the Application Settings page of the new project wizard, check the "Empty Project" checkbox.

    Then when the project opens, Add existing item and select any and all files that you have. You can compile those separately, and if you create a new cpp file with a main() function you can build the whole thing into an executable.

  5. #20
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I am working on a personal project which requires me to generate large amounts of truly random numbers (hint: its about probabilities).
    Are you sure you need a "truly" random number?

    My philosophy is that it's "random enough" if it's unpredictable (and usually evenly distributed... assuming you don't want a particular bias, or some particular statistical distribution.) For example, the machines in casinos are not using any sort of quantum random generator, and most probability simulations also use pseudorandom numbers.

  6. #21
    Registered User
    Join Date
    May 2008
    Posts
    81
    Quote Originally Posted by DougDbug View Post
    Are you sure you need a "truly" random number?

    My philosophy is that it's "random enough" if it's unpredictable (and usually evenly distributed... assuming you don't want a particular bias, or some particular statistical distribution.) For example, the machines in casinos are not using any sort of quantum random generator, and most probability simulations also use pseudorandom numbers.
    lol @ "[b]it's". yea, you're right...anything unpredictable enough is good enough to be random. i guess what i meant was that i wanted something better than rand()/srand(). just happened to run into the qrbg, it was free AND it had a C++ library so it looked ideal for me.

    now, if I can just figure out how to get MS VC++ to work

  7. #22
    Registered User
    Join Date
    May 2008
    Posts
    81
    Quote Originally Posted by Daved View Post
    Create a project. Unless you are making a windows application, you want a console application. The project should be a Win32 Console Application. I believe it is still called that in VC++ 2008. Be careful, there are other similar ones that use .NET and you don't want that.

    In the Application Settings page of the new project wizard, check the "Empty Project" checkbox.

    Then when the project opens, Add existing item and select any and all files that you have. You can compile those separately, and if you create a new cpp file with a main() function you can build the whole thing into an executable.
    ok i did as you said...i created the project as a Win32 console app and checked 'empty project', then added my cpp to it. now how do I compile? when i hit build, I get the following error:

    Code:
    1>------ Build started: Project: test, Configuration: Debug Win32 ------
    1>Embedding manifest...
    1>.\Debug\test.exe.intermediate.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
    1>Build log was saved at "file://c:\Documents and Settings\Shar\test\test\Debug\BuildLog.htm"
    1>test - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    this was running ok on borland???

  8. #23
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    I don't think you picked Win32 Console Application, I think you picked something that was close to that but not exactly that. I don't have VC++ 2008 in front of me to verify, though.

    The reason you want Win32 Console Application is because that particular project type doesn't add the .NET stuff used in C++/CLI or Managed C++. I think the manifest is part of that.

    Create another new project and check to see if maybe there is a similar project type in a different category that is closer to Win32 Console Application. If there isn't, then maybe I'm wrong and you'll have to find a way to turn off the manifest stuff in your current project.

    Maybe turn off ATL and MFC support in the application wizard?
    Last edited by Daved; 05-16-2008 at 08:32 PM.

  9. #24
    Registered User
    Join Date
    May 2008
    Posts
    81
    ok, i'm compiling via the command prompt using cl /EHsc file.cpp

    all the previous errors went away. instead i started getting these:

    Code:
    example0.cpp
    c:\qrbg\src\QRBG.h(339) : error C2079: 'QRBG::timeStart' uses undefined struct '
    timeval'
    c:\qrbg\src\QRBG.h(339) : error C2079: 'QRBG::timeEnd' uses undefined struct 'ti
    meval'
    in QRBG.h, i noticed that this line is # if defined (PLATFORM_LINUX)...so i commented the lines out.

    now, i'm getting these errors:

    Code:
    /out:example0.exe
    example0.obj
    example0.obj : error LNK2019: unresolved external symbol "public: __thiscall QRB
    G::~QRBG(void)" (??1QRBG@@QAE@XZ) referenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: unsigned int _
    _thiscall QRBG::getBytes(unsigned char *,unsigned int)" (?getBytes@QRBG@@QAEIPAE
    I@Z) referenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: double __thisc
    all QRBG::getDouble(void)" (?getDouble@QRBG@@QAENXZ) referenced in function _mai
    n
    example0.obj : error LNK2019: unresolved external symbol "public: float __thisca
    ll QRBG::getFloat(void)" (?getFloat@QRBG@@QAEMXZ) referenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: long __thiscal
    l QRBG::getLongInt(void)" (?getLongInt@QRBG@@QAEJXZ) referenced in function _mai
    n
    example0.obj : error LNK2019: unresolved external symbol "public: int __thiscall
     QRBG::getInt(void)" (?getInt@QRBG@@QAEHXZ) referenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: unsigned char
    __thiscall QRBG::getByte(void)" (?getByte@QRBG@@QAEEXZ) referenced in function _
    main
    example0.obj : error LNK2019: unresolved external symbol "public: void __thiscal
    l QRBG::defineUser(char const *,char const *)" (?defineUser@QRBG@@QAEXPBD0@Z) re
    ferenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: void __thiscal
    l QRBG::defineServer(char const *,unsigned int)" (?defineServer@QRBG@@QAEXPBDI@Z
    ) referenced in function _main
    example0.obj : error LNK2019: unresolved external symbol "public: __thiscall QRB
    G::QRBG(unsigned int)" (??0QRBG@@QAE@I@Z) referenced in function _main
    example0.exe : fatal error LNK1120: 10 unresolved externals
    help!

  10. #25
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    The linker cannot find those functions. Are they defined in another cpp file that you didn't compile?

  11. #26
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    if you want really simple and very random numbers use uinitialized pointers

  12. #27
    Registered User
    Join Date
    May 2008
    Posts
    81
    Quote Originally Posted by (::) View Post
    if you want really simple and very random numbers use uinitialized pointers
    how so?

  13. #28
    Registered User
    Join Date
    May 2008
    Posts
    81
    Quote Originally Posted by Daved View Post
    The linker cannot find those functions. Are they defined in another cpp file that you didn't compile?
    i guess the only other file they could be in would be qrbg.cpp. but that's not included anywhere...then why would its functions be referenced? how do i run them all together on the cmd prompt?

  14. #29
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by (::) View Post
    if you want really simple and very random numbers use uinitialized pointers
    Uninitialized pointers are not reliable sources of random numbers. They could be all-bits zero or predicatable data from a previous program.
    Quote Originally Posted by shawnt View Post
    how so?
    They're not. I think he was joking.
    Last edited by robwhit; 05-17-2008 at 11:53 AM.

  15. #30
    Registered User
    Join Date
    May 2008
    Posts
    81
    ok those functions were indeed from qrbg.cpp. so i ran them together, like so:

    cl /EHsc example0.cpp qrbg.cpp

    now, i just have 2 dozen new errors . oh well, back to work.

Page 2 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with random number generator
    By Niss in forum C Programming
    Replies: 6
    Last Post: 10-01-2008, 06:03 PM
  2. Replies: 1
    Last Post: 09-04-2007, 05:31 AM
  3. Random card generator
    By Loic in forum C++ Programming
    Replies: 13
    Last Post: 08-11-2007, 02:28 PM
  4. Random number generator between 0 and 1
    By Lord CyKill in forum C# Programming
    Replies: 1
    Last Post: 03-29-2007, 08:03 AM
  5. Fast normal random number generator
    By testing123 in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2006, 10:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21