Problem with static library linking

Harish harish@in.niksun.com
Mon Mar 24 12:38:00 GMT 2008


Hi,

I am having a problem with the static library as explained below.


There was an existing static library libpcap.a 
I created a new static library with the name mylib.a , mylib.a calls a function func() in libpcap.a.

I created mylib.a using the below command

ar rcs mylib.a *.o libpcap.a
ranlib mylib.a

mylib.a has been successfully made. 

But when I use mylib.a with an executable it says undefined symbol for the function func() in the file which is present in mylib.a.

I used the command "nm mylib.a | grep func" to verify that mylib.a actually contains func().

But still I am getting linking error.

In my link line  libpcap.a comes before mylib.a

Could you please help.

I would be very thankful.

-Harish




More information about the Gcc-help mailing list