@taby Your second (working) code isn't exactly the same as the first description. For proper checking, you should make them literally as much the same as possible. You don't want to introduce more sources of confusion until you found the culprit. Alternatively, you could try the working initialization in your non-working version.
Also, draw a random number directly after initializing in the non-working version, like you do in the working version. (Keep things literally equal.)
For debugging, print the seed value that you use for initializing (it should change in time). A second step is to also print the raw drawn numbers everywhere. Since your generator is global, it is initialized before main even starts with some default (probably fixed), and perhaps even used. With all the above output you should be able to see if initializing happens before use.
If that works, perhaps it's your ‘u’ in your non-working version? Split the statement, and print the raw mt sample before using it in ‘u’.