473,659 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to eliminate multiple declaration error for a symbol present inboth libs( without modifying libs)

Hi All,
I have two libs (libFirst.a and libSecond.a). Both libs contains a
common function func(). Now I want to link an application "app" with
these two libs as

gcc -o app libFirst.a libSecond.a app.c.

It gives( and it should ) multiple declaration error . Is there any
way to tell the linker which func() declaration it must select.

NOTE: app need to be linked two both these libs.

Thanks and regards,
Raman Chalotra.
Mar 25 '08 #1
1 1808
On Apr 7, 11:00 am, David Thompson <dave.thomps... @verizon.netwro te:
On Mon, 24 Mar 2008 21:21:09 -0700 (PDT), Raman

<ramanchalo...@ gmail.comwrote:
I have two libs (libFirst.a and libSecond.a). Both libs contains a
common function func(). Now I want to link an application "app" with
these two libs as
gcc -o app libFirst.a libSecond.a app.c.
It gives( and it should ) multiple declaration error . Is there any
way to tell the linker which func() declaration it must select.

Small but important terminology point: multiple _definition_.

A _definition_ in C provides the actual entity (an object, commonly
called a variable, or a function), and having more than one for the
same external name is a problem. Although one that the C standard does
not require an implementation to detect; you are mildly lucky that
your implementation did.

A _declaration_ is _sometimes_ (also) a definition, but when it isn't,
it only describes something defined elsewhere. It is definitely OK to
have external declarations in different T.U.s for the same external
entity, and that's the only (direct) way you can share it; it is also
legal to have multiple (compatible) declarations for the same external
entity in one T.U, and sometimes convenient.

That said, others have addressed the substance of your question.

- formerly david.thompson1 || achar(64) || worldnet.att.ne t
Taken a note of my ignorance.

Thanks,
Raman Chalotra
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1019
by: pmud | last post by:
Hi, An ASP.NET project has been DEPLOYED to the WEB SERVER. I modified one of the pages in the DEVELOPMENT SERVER & tried to replace the Existing page in the project (which has already been deployed on WEB SERVER). So I simply replaced the old page with the modified page in the location C:/Inetpub/wwwroot on Web Server But when I try to view the modified through browser I get an error that the resource has been moved. Evn though I...
4
3043
by: ben | last post by:
why is it, in the below code, when there's a printf statement (the one commented with /* ****** */) the final for loop prints out fine, but without the commented with stars printf statement included in the code there's a bus error on the fourth element in the final for loop? final for loop print out when the /* ****** */ printf line is included in the code: ab ba
0
1119
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in the site inherit from. In addition to providing basic functionality and security, this Page class modifies the HtmlForm controls collection in the deriving page to manage the page layout. The Page class adds LiteralControls to manipulate the page...
1
1146
by: Larry Brown | last post by:
Hi, I know that I should not, but believe me I really have to do that: I'm developping an ASP.NET application with Visual Studio .NET 2003 installed on my workstation, on a server which is on a different domain. Meaning the application is installed on a server which is on a different domain than the one where my workstation with my Visual Studio is. This application is running normally, I have access with my account to the server both...
0
809
by: NetRacer | last post by:
hi all, i have the following piece of code: Property xyz As Object Get End Get Set(ByVal Value as Object)
8
12518
by: D & J G | last post by:
A VB6 program that I created has been installed on a wide range of computers and networks without any problems. Win 95, Win 98 and XP so far.. Occasionally, however, the function refuses to start on some systems, with the only response being a critical error: 'Unexpected Error!', without even trying to run. Well! I didn't expect it, either! Re-compiling and re-installing doesn't change anything. The program is nothing really...
8
4873
by: Ian | last post by:
Consider that I have a "non-extern" function that takes no parameters. Which of the following would be ANSI C90 compliant: void hello(void) { printf("Hello\n"); } or
0
1658
by: Steve Rainbird | last post by:
I am brand new to db2 so I may be doing something stupid here please excuse me if I am. I have downloaded and installed db2 9 express on my Windows xp system. I have created a table with 2 columns in it. When I view the table in control center and try and change some of the data or add a row I get the error CLI0612E Invalid parameter number. SQLSTATE=S1093
1
1319
by: TRiggs | last post by:
A SQL database was restored over in error. A backup of the original database was not created prior to the restore. Is there anyway to recover this database?
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.