cudaGraphicsGLRegisterBuffer throwing exception : Access violation writing location

Hi,
I was using CUDA OpenGL interoperability successfully when I wrote my code referencing Particle Simulation
using CUDA in CUDA examples. However, when I am trying to add it to other existing Qt application, an exception was thrown at (nvcuda64.dll): Access violation writing location from cudaGraphicsGLRegisterBuffer(cuda_vbo_resource, vbo, cudaGraphicsMapFlagsNone).

My OpenGL version is 4.6, CUDA version is 12.1. The successfully running code uses glutinit() while the Qt application uses glewinit(). Can anybody help me find out what went wrong from the Qt application?