Added compatibilty for dlopen so that library can be checked at runtime.
Also made necessary changes in the example required for dlopen.