Search code examples
c++macoslsof

Why doesn't lsof show that libstdc++ is loaded on Mac OS X?


I have an application that I know uses libstdc++, but even as the super user, I cannot see /usr/lib/libstdc++.6.0.9.dylib on my Mac OS X 10.6 Snow Leopard system?

lsof | grep libstdc++

If I use DYLD_LIBRARY_PATH to use my own copy of libstdc++ it shows up in the full path while my app is running:

fooo 1701 foooo  txt      REG               14,5     2439888   54431 /path/to/shared/libstdc++.6.0.9.dylib

This is after a fruitless google search. On a linux system, any user can see which applications are using the library in /usr/lib.


Solution

  • I guess the reason is libstdc++ is considered a system library in OS X and is treated differently than other user libraries.

    If you want the system to load it just like a user supplied library use something like:

    export DYLD_SHARED_REGION=avoid
    ./your_program_name
    

    man dyld for more information on what the above environment setting means.