From owner-freebsd-hackers Mon Feb 14 6: 0:17 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from www.geocrawler.com (sourceforge.net [198.186.203.33]) by builder.freebsd.org (Postfix) with ESMTP id C2500425C for ; Mon, 14 Feb 2000 06:00:13 -0800 (PST) Received: (from nobody@localhost) by www.geocrawler.com (8.9.3/8.9.3) id GAA29194; Mon, 14 Feb 2000 06:00:21 -0800 Date: Mon, 14 Feb 2000 06:00:21 -0800 Message-Id: <200002141400.GAA29194@www.geocrawler.com> To: freebsd-hackers@freebsd.org Subject: Help me understand dlopen/dlsy From: "Pradesh Chanderpaul" Reply-To: "Pradesh Chanderpaul" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message was sent from Geocrawler.com by "Pradesh Chanderpaul" 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 #include #include 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 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