78dd1bbdb1a5776a9e87b4f94dd68bc06aec41e8
[metaproxy-moved-to-github.git] / src / tstdl.cpp
1 /* $Id: tstdl.cpp,v 1.4 2006-06-10 14:29:13 adam Exp $
2    Copyright (c) 2005-2006, Index Data.
3
4    See the LICENSE file for details
5  */
6
7 #include "config.hpp"
8
9 #include <stdlib.h>
10 #include <iostream>
11 #if HAVE_DLFCN_H
12 #include <dlfcn.h>
13 #endif
14
15 using namespace std;
16
17 int main(int argc, char **argv)
18 {
19 #if HAVE_DLFCN_H
20     if (argc != 3)
21     {
22         cerr << "bad args" << endl << "Usage: tstdl filename symbol" << endl;
23         exit(1);
24     }
25     void *mod = dlopen(argv[1][0] ? argv[1] : 0, RTLD_NOW|RTLD_LOCAL);
26     if (!mod)
27     {
28         cerr << "dlopen failed for file '" << argv[1] << "'\n" <<
29             "dlerror=" << dlerror() << endl;
30         exit(1);
31     }
32     void *sym = dlsym(mod, argv[2]);
33     printf("sym=%p\n", sym);
34     dlclose(mod);
35     exit(0);
36 #else
37     cerr << "dl lib not enabled or not supported" << endl;
38     exit(1);
39 #endif
40
41 }
42 /*
43  * Local variables:
44  * c-basic-offset: 4
45  * indent-tabs-mode: nil
46  * c-file-style: "stroustrup"
47  * End:
48  * vim: shiftwidth=4 tabstop=8 expandtab
49  */