Can I use .o files of compiled c files and use that to compile SV files for DPI

In reply to Ankit_Patel:

//Created shared library using below command
gcc -shared -fPIC -Bsymbolic -o test.so test.c main.c

//Simulating shared library with Questasim
vlib work
vlog -sv tb_dpi.sv
vsim -sv_lib test -c tb_dpi -do “run -all”

//Created executable using below command
gcc -o test test.so

Now problem here is my GUI sets some variable in test.c file but my systemverilog code dosen’t gets the updated value.
I thing Questa dosen’t get’s updated from .so at runtime. So is there a way to run executable in Questasim so that sv code gets updated value or any other suggestions?