How do I tell gcc (or ld) to link against debug versions of the standard c and c++ libraries

前端 未结 3 1312
陌清茗
陌清茗 2021-01-06 02:12

I have debug versions of libstdc++ and libc, among others, and would like to link against them. They live in /usr/lib/debug as opposed to /usr/lib. Any ideas?

3条回答
  •  情话喂你
    2021-01-06 03:04

    Assuming Linux,

    1. Static libraries: add a -L/usr/lib/debug to your linker command line. gcc/ld will look there before default system directories. Use ldd command to verify that correct library versions were linked against (shared libraries only).
    2. Shared libraries: set LD_LIBRARY_PATH=usr/lib/debug, and your application will pick up libraries from there even without step 1, as long as there is a version of a library, which is very likely if you are installing with distribution's package manager.

    It's a good idea to do both, though, as some libraries may be only in static form.

提交回复
热议问题