Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what’s the dynamic library search algorithm with it?

As you’ve noted, DYLD_LIBRARY_PATH behaves like LD_LIBRARY_PATH on other *nix. However, there is another environment variable you should look at called DYLD_FALLBACK_LIBRARY_PATH. In general, these are (both on osx and linux) suggested only for development use as they can cause symbol lookup errors when you override with a library that does not have the same … Read more

What happens to global and static variables in a shared library when it is dynamically linked?

This is a pretty famous difference between Windows and Unix-like systems. No matter what: Each process has its own address space, meaning that there is never any memory being shared between processes (unless you use some inter-process communication library or extensions). The One Definition Rule (ODR) still applies, meaning that you can only have one … Read more

What do linkers do?

To understand linkers, it helps to first understand what happens “under the hood” when you convert a source file (such as a C or C++ file) into an executable file (an executable file is a file that can be executed on your machine or someone else’s machine running the same machine architecture). Under the hood, … Read more

What do ‘statically linked’ and ‘dynamically linked’ mean?

There are (in most cases, discounting interpreted code) two stages in getting from source code (what you write) to executable code (what you run). The first is compilation which turns source code into object modules. The second, linking, is what combines object modules together to form an executable. The distinction is made for, among other … Read more

Static linking vs dynamic linking

Dynamic linking can reduce total resource consumption (if more than one process shares the same library (including the version in “the same”, of course)). I believe this is the argument that drives its presence in most environments. Here “resources” include disk space, RAM, and cache space. Of course, if your dynamic linker is insufficiently flexible … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)