when a lib needs a lib

Hi,
I don’t know if I missed something but I wrote a shared lib say lib1.so
that use fabs() and so needs the libm.so.
So, I’ve added:
LIBS+= m

in its common.mk.

if the executable which is supposed to load lib1.so hasn’t been built
with libm, fabs() will be unresolved.

Why?

Thanks,
Alain

I had this problem once before and assumed that I would just have to link
the end application with both libraries. Colin has informed me, however,
that if your lib is compiled as a shared object and linked against libm
then it will have a reference to needing libm which will get loaded at
startup.

So, the answer is to create your library as a shared lib rather than static.
If you need it to be static, you’ll just have to link against libm when
you compile your app.

Cheers,

Kris

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Hi,
I don’t know if I missed something but I wrote a shared lib say lib1.so
that use fabs() and so needs the libm.so.
So, I’ve added:
LIBS+= m

in its common.mk.

if the executable which is supposed to load lib1.so hasn’t been built
with libm, fabs() will be unresolved.

Why?

Thanks,
Alain


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“I love deadlines. I like the whooshing sound they make as they fly by.”
– Douglas Adams

Kris Eric Warkentin a écrit :

I had this problem once before and assumed that I would just have to link
the end application with both libraries. Colin has informed me, however,
that if your lib is compiled as a shared object and linked against libm
then it will have a reference to needing libm which will get loaded at
startup.

So, the answer is to create your library as a shared lib rather than static.
If you need it to be static, you’ll just have to link against libm when
you compile your app.

Cheers,

Kris

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Hi,
I don’t know if I missed something but I wrote a shared lib say lib1.so
that use fabs() and so needs the libm.so.
So, I’ve added:
LIBS+= m

in its common.mk.

if the executable which is supposed to load lib1.so hasn’t been built
with libm, fabs() will be unresolved.

Why?

Thanks,
Alain


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“I love deadlines. I like the whooshing sound they make as they fly by.”
– Douglas Adams

Thanks Kris but I don’t really know what was the problem exactly because it
works like that now.
I don’t know why I had to specify the libm for the main executable. I will try
to understand what happened.

Thanks,
Alain.