Date: Mon, 14 Feb 2000 06:00:21 -0800 From: "Pradesh Chanderpaul" <archiver@db.geocrawler.com> To: freebsd-hackers@freebsd.org Subject: Help me understand dlopen/dlsy Message-ID: <200002141400.GAA29194@www.geocrawler.com>
next in thread | raw e-mail | index | archive | help
This message was sent from Geocrawler.com by "Pradesh Chanderpaul" <pradesh.chanderpaul@iname.com> Be sure to reply to that address. Hello All I know that this question is more suited to the general questions mailing group, but I tried, and failed to obtain a response. So could someone please provide guidance with this topic. I have searched the mailing lists, man pages and the net at large without getting a satisfactory understanding. Consider the following scenario. I need to compile a program consisting of two source files and a makefile file1.c ------- #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int main() { void *handle; void (*myhellofunc)(void); char *c; handle = dlopen(NULL, 1); c = dlerror(); if (c) abort_with_error(c); myhellofunc = dlsym(handle, "_helloworld"); c = dlerror(); if(c) abort_with_error(c); myhellofunc(); dlclose(handle); } file2.c ------- #include <stdio.h> void helloworld(void) { printf(" Hello cruel worldn"); } Makefile -------- file1.o : file1.c gcc -fPIC -c file1.c file1.o : file1.c gcc -fPIC -c file1.c fileit : file1.o file2.o cc -export-dynamic -o fileit file1.o file2.o The two source files will be linked into a single executable, using GCC running on FreeBSD 3.2-RELEASE. Q1 : Are my flags sufficient to compile the individual source files? Q2 : What flags are required to link the object files into the single executable? Q3 : Is there anything else I should be wary of? I have tried various options (like using -rdynamic and -shared but to no avail. dlerror() reports an undefined symbol for _helloworld from calling dlsym. This issue has been "bugging" me for weeks now, so I need to try and get it sorted out. Please assist if you can. Thanking you in advance. Pradesh Chanderpaul Geocrawler.com - The Knowledge Archive To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200002141400.GAA29194>