I have resolved the error.
The reason is the way I was including the header file.
The function func() present in the file ipv6hdrs.h( definition in ipv6hdrs.c) and in the library libpcap.a
In the library mylib.a and in the file test.cc I included ipv6hdrs.h as below
#include "ipv6hdrs.h"
Later I noticed that the definition of func() is present in the .c file rather than .cc file.
So I changed the header file inclusion to
extern C
{
#include "ipv6hdrs.h"
}
and it worked. I could build my executable properly.