Try using C++ interface but files dosen't compile well

Hi, I’m not sure if I’m doing it well - I try to compile CPP file to prolog file using the swipl library.
But after compiling with the command: swipl-ld -gcc -o output myfile.cpp
the output file is from type output.so and it doesn’t work when I consult it. doesn’t also work to define -o output.pl

what I’m doing wrong?
Generally, I think it will be very helpful to have a tutorial for beginners step by step
Thank you