home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!math.fu-berlin.de!ira.uka.de!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!uwm.edu!linac!att!cbnewsc!cbfsb!cbnewsg.cb.att.com!nh
- From: nh@cbnewsg.cb.att.com (nicholas.hounsome)
- Subject: Re: Dynamic Linking and Sun Sparcs, do they mix?
- Message-ID: <1993Jan28.091112.3088@cbfsb.cb.att.com>
- Sender: news@cbfsb.cb.att.com
- Organization: AT&T
- References: <1993Jan27.192131.14505@ucc.su.OZ.AU>
- Date: Thu, 28 Jan 1993 09:11:12 GMT
- Lines: 53
-
- I have started to investigate DLLs on the sun and all seems to work
- as expected.
-
- This was my first test program which incidentaly gives me some good ideas for
- a simple config file reader or debugging interface:
-
- #include <stdio.h>
- #include <dlfcn.h>
- int a()
- {
- printf("a called\n");
- }
-
- int b()
- {
- printf("b called\n");
- }
-
- main()
- {
- char buf[200];
- void *handle;
- void *handle2;
- void *handle3;
- int (*f)();
- handle = dlopen(NULL,1);
- handle2 = dlopen("/usr/lib/libc.so.1.7",1);
- handle3 = dlopen("/usr/openwin/lib/libX11.so.4.3",1);
- while(gets(buf))
- {
- f = dlsym(handle,buf);
- if( f )
- f(buf) ;
- else
- {
- f = dlsym(handle2,buf);
- if( f )
- f("called %s\n",buf) ;
- else
- {
- f = dlsym(handle3,buf);
- if( f )
- f("called %s\n",buf) ;
- else
- {
- printf("no function %s\n", buf);
- }
- }
- }
- }
- }
-
- Nick Hounsome
-