Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > The Community > Everything BSD
Reload this Page problem with static library linking
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Everything BSD For all discussions regarding Free/NetBSD and OpenBSD.

Reply
 
Thread Tools Display Modes
Old 03-25-2008   #1 (permalink)
send2harish
Just Joined!
 
Join Date: Mar 2008
Posts: 2
problem with static library linking

Hi All,

I have a problem with the linking as explained below.


I created a new library mylib.a which uses a function func() present in the already existing library libpcap.a.

When I build mylib.a I did not see any error.

But when I build mylib.a with an executable I got a linking error of undefined reference to the function func(). Thi error was shown in a file which is present in mylib.a

On my link line I have tried the following order of linking.

1. libpcap.a mylib.a
2. mylib.a libpcap.a

But I am still having this error.

Could you please help me out.

Regards
-Harish
send2harish is offline   Reply With Quote
Old 03-27-2008   #2 (permalink)
send2harish
Just Joined!
 
Join Date: Mar 2008
Posts: 2
Smile Re:problem with static library linking

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.
send2harish is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 06:05 AM.

Powered by vBulletin 3.6.8 ©2000 - 2007, content relevant URLs by vBSEO, Property of Core Root.

Content Relevant URLs by vBSEO 3.0.0