LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-01-2006, 03:49 AM   #1
durgaprasad_j
LQ Newbie
 
Registered: Jan 2005
Posts: 1

Rep: Reputation: 0
Problem in using both load time linking and runtime linking


Hi All,

I have a small shared library file named libtest1.so

I have written a small program to load this library in runtime
using dlopen, dlclose etc. In that program I open that library using
dlopen once and close that library twice using dlclose.

So, when I compile the program normally, gcc test.c -ldl, it is
working fine. It is printing dlerror message when it is executing
dlclose second time.

But, when I compile the program with load time linking also, gcc
test.c -L<somedir> -ldl -ltest1, 2nd dlclose is also working fine in
some systems with out any error message from dlerror function. I have
tested this program in 2 linux systems. In RHEL AS Release 4, KERNEL:
2.6.9-34.0.2.EL , it is printing dlerror after 2nd dlclose [This is
what I have expected]. But in Suse 8.1, KERNEL: 2.4.21-138-default,
even the 2nd dlclose result is SUCCESS.

I dont know how system handles if load time linking and runtime
linking is done on the same libraries. If you know it, please explain
me.

If anyone of you have faced this kind of problem earlier and solved
them, please help me.

/*
This is the C Program that I have written.
*/
#include<stdio.h>
#include<dlfcn.h>
int main(int argc,char* argv)
{
void* handle_test1=dlopen("libtest1.so",RTLD_NOW|RTLD_GLOBAL);
if(!handle_test1)
printf("Test1 Error\n");
else
printf("test1 open is succesful\n");

int close_val=dlclose(handle_test1);
printf("test1 close#1 is %d , %s \n",close_val,dlerror());
close_val=dlclose(handle_test1);
printf("test1 close#2 is %d , %s \n",close_val,dlerror());
}

Thank you
Durga Prasad
 
  


Reply

Tags
linking



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Problem I think? gplacek Linux - Software 10 08-13-2004 07:01 PM
ld linking problem captain-mythos Linux - Software 1 06-20-2004 08:46 AM
C++ Linking Problem acjt Programming 4 01-31-2004 08:48 AM
Problem linking Red Guy Programming 1 02-07-2003 03:52 AM
linking problem with ld ! gluon Programming 2 05-19-2002 01:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration