Helper to access dynamic shared objects (DSO)
Example:
#include <lunchbox/test.h>
#include <lunchbox/dso.h>
#include <boost/filesystem.hpp>
#ifdef __linux__
# include <gnu/lib-names.h>
#endif
#ifdef _WIN32
# include <lunchbox/os.h>
# define fork CreateThread
const std::string forkFun( "CreateThread" );
#else
const std::string forkFun( "fork" );
#endif
namespace fs = boost::filesystem;
int main( int, char** )
{
#ifdef _WIN32
libraries.push_back( "Kernel32.dll" );
libraries.push_back( "Ws2_32.dll" );
#elif defined (Darwin)
libraries.push_back( "/usr/lib/libc.dylib" );
libraries.push_back( "/usr/lib/libtermcap.dylib" );
#else
libraries.push_back( LIBC_SO );
libraries.push_back( LIBM_SO );
#endif
TEST( one.isOpen( ));
TEST( two.isOpen( ));
TEST( one != two );
TEST( one != three );
TEST( three.
open( libraries[0] ));
TEST( one == three );
TEST( !three.
open( libraries[0] ));
TEST( one == three );
TEST( one.getFunctionPointer( forkFun ));
TESTINFO( one.getFunctionPointer( forkFun ) == &fork,
one.getFunctionPointer( forkFun ) << " != " << (void*)&fork );
TEST( !one.getFunctionPointer( "fooBar" ));
one.close();
TEST( one != two );
TEST( one != three );
TEST( !one.getFunctionPointer( forkFun ));
two.close();
TEST( one == two );
TEST( one != three );
return EXIT_SUCCESS;
}
Definition at line 35 of file dso.h.