It looks like you are interested in dynamic loading , and not generally a link. How ODBC finds and uses a specific driver at runtime, for example, what you want to do with your resolver.
Instead of getting a random link to google, I will give you some dynamic linking keywords:
Basic concepts: "dynamic loading" "Value" Independent position code "
Tools: LD_DEBUG ldconfig ldd nm objdump
C API for dynamic loading: dlfcn.h dlopen dlsym dlerror dlclose
I found one good tutorial that I remember was useful when I was working with ODBC: http://www.ibm.com/developerworks/library/l-shobj/
However, he recommends accessing ld directly, which does not matter gcc. Use the -shared option instead:
g++ -shared -fPIC foo.c -o libfoo.so.1.0 -Wl,soname,libfoo.so.1
Also: you should look for solutions that do not include LD_PRELOAD or LD_LIBRARY_PATH, which are mostly debugging tools, and libraries that require them in production are wrong: Why LD_LIBRARY_PATH is bad LD_LIBRARY_PATH is not LD_LIBRARY_PATH's answer - just say no
ODBC avoids it with the odbc.ini configuration file, where you specify the full path to .so to use.
source share