I'm compiling c++ code and I'm trying to add in the -rdynamic option so I can print out a meaningful stack trace for debugging my c++ program, but clang throws back a warning saying "argument unused during compilation: '-rdynamic'".
As a test, on my system I've tried writing a simple c++ program and compiling it with -rdynamic and it worked no problem, but with this project it doesn't seem to go.
Any advice is much appricated
You are likely using the
-rdynamic
flag when you are just compiling the source code, not linking it. It's a flag for the linker, so you only need it when linking. Some versions of clang might not recognize it, in which case you can just instruct clang to pass the proper option to the linker, which commonly is:So, e.g.
or
But if you are compiling and linking separately, only use it at the linking stage:
(or as the last step:
clang++ -rdynamic test.o
)