[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: library fuction calls

On Thu, 22 Feb 2001, Raja Subramanian wrote:

> That's news, _nothing_except_ echo worked on my linux box. I could not run
> anything if I compiled the the library as you have mentioned. Are you sure
> youre not missing something?
	This is what I did:

<ajayd:tconn> cc -o malloc_interposer.so -shared malloc_interposer.c
<ajayd:tconn> export LD_PRELOAD=/home/ajayd/tconn/malloc_interposer.so 
  (you have to give the complete path for the library)
<ajayd:tconn> ls
ls: error in loading shared
libraries: /home/ajayd/tconn/malloc_interposer.so: undefined symbol: dlsym
<ajayd:tconn> /bin/echo
malloc(176) is called
malloc(176) is called

	I noted that it does not work with ls, clear, strace etc . Works
for vim, /bin/echo etc.. (NOTE: there is also a bash builtin echo, so the
need for /bin/echo to test)

> > 	Any ideas ?
> Yes, you need to include libdl in linux (RTFineM, sorry); add -ldl to your gcc
> flags. As you see, Solaris and linux are not the friendliest when it comes to
> linking in libraries and I've been bitten by this many times too.
	Oops!! ... After reading your mail, I had been trying for the last
hour to compile with -ldb, just figured out you said -ldl. Going for a
strong coffee break :-)

	Now it is working for all, ls , clear, strace etc.... and I am a
happy guy :)

	Thanks Raja, sandeep and binand and others. Its great to be on LI

#!!!	If anything can go wrong, _FIX_ it. (To hell with MURPHY)
						Ajay kumar Dwivedi