I have a solution for this
when i was trying to compile my code in bash shell
g++ solution.cpp -o solution
it gave an error of this collect2.exe: error: ld returned 116 exit status
the issue I faced was there were two g++ bin file in my computer
one is ucrt64 folder and one in mingw64
you want to test by which your code is running and use that one or else you can download the code runner extension on vscode it does the job and compiles the c++ file into .exe and then you just run the .exe file simply
but if you want to this in terminal you can always and set an alias of g++ to your bin path g++ file
or you can simply do
export PATH=/c/msys64/ucrt64/bin:$PATH
if all this doesnt work then sorry bro :(