metaproxy 1.22.1
tstdl.cpp
Go to the documentation of this file.
1/* This file is part of Metaproxy.
2 Copyright (C) Index Data
3
4Metaproxy is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#include "config.hpp"
20
21#include <stdlib.h>
22#include <iostream>
23#if HAVE_DLFCN_H
24#include <dlfcn.h>
25#endif
26
27using namespace std;
28
29int main(int argc, char **argv)
30{
31#if HAVE_DLFCN_H
32 if (argc != 3)
33 {
34 cerr << "bad args" << endl << "Usage: tstdl filename symbol" << endl;
35 exit(1);
36 }
37 void *mod = dlopen(argv[1][0] ? argv[1] : 0, RTLD_NOW|RTLD_LOCAL);
38 if (!mod)
39 {
40 cerr << "dlopen failed for file '" << argv[1] << "'\n" <<
41 "dlerror=" << dlerror() << endl;
42 exit(1);
43 }
44 void *sym = dlsym(mod, argv[2]);
45 cout << "sym=" << sym << endl;
46 dlclose(mod);
47 exit(0);
48#else
49 cerr << "dl lib not enabled or not supported" << endl;
50 exit(1);
51#endif
52
53}
54/*
55 * Local variables:
56 * c-basic-offset: 4
57 * c-file-style: "Stroustrup"
58 * indent-tabs-mode: nil
59 * End:
60 * vim: shiftwidth=4 tabstop=8 expandtab
61 */
62
int main(int argc, char **argv)
Definition tstdl.cpp:29