473,794 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Libraries, function names and link

Hello everybody,

Although I am sure this is an important question for this group, I
am not sure this question belongs to this group and I will be
happy to move it to the correct one after you point it to me.

Direct question:
How can I know if a function is defined in more than one static
library that I am using to link ?

More information:
We have a huge project with about 40 libraries, some of them are
third part libraries.
One day, when I got a new third part library release, I luckly
started getting a link error because a function called FileExists
was being defined in two libraries.
I said luckly because if I invert the order that the libraries are
being linked, I could not see the error and in that case who knows
what funcion was being used.
( of course I know, but it might be the wrong one and the problem
might showup two months from now and it must not show up )

The problem I am trying to avoid is: having two functions in two
different libraries with the same name, in this case, the function
that will be linked depend on the position of the libraries in the
link command.

I know that this is the beaulty of libraries, that we can override
functions, but I would like to be aware that this situation is
happening.

Also I know that is common sense that the libraries should have a
prefix in their name function, like the foo.lib should have
function names as foo_function1 or something like that, but this
is a convention and that can fail when using third part libraries.

Also can be argued that I should know the function names in the
libraries, but in this project we are talking about of thousands
of functions, lots of them are bought without source code, so it
is not pratical to do so, but even if this was pratical I would
like to have a computer checking to me.

I looked into my link for any option that would do that and I
could not find ( for references I use the ADS arm toolkit )

The ideal solution would be having a utility that will check the
libraries for me, or something else with the same idea.

I work in this area for many years and never thought about this
problem, until it bit me and know I think this is a problem that
could bite anyone, but I am not finding answers until now.

Please let me know if you need more information and any comments
are welcome.

Thanks in advance

Jose Luis Marchetti

Nov 15 '05 #1
3 2326
In article <11************ **********@g47g 2000cwa.googleg roups.com>,
<jo************ ***@yahoo.com.b r> wrote:
Although I am sure this is an important question for this group, I
am not sure this question belongs to this group
It doesn't really. It would be better put in a newsgroup specific
to your programming environment.
Direct question:
How can I know if a function is defined in more than one static
library that I am using to link ?


You mention the ADS arm toolkit but you do not happen to mention
which platform you are running on.

As a generalization, unix-like platforms often provide tools such as
'nm' which can be used to ask a library for a list of symbols that it
defines.

The following gets unix-specific.
I happen to prefer the "Berkeley" style output of 'nm', the -B option.
With it, you look for items marked with D (a data definition with
initialization) or with T (a "text" = code definition). Some systems also
use B (a data definition of an object to be zero'd at startup),
G (small initialized data definition) and S (small zeroed data
definition).

For example,

$ nm -B /usr/freeware/lib32/libpcap.so |egrep ' [BDT] ' | head
00000000 T __dso_displacem ent
08a80000 T __elf_header
08a8d9cc T __pcap_atodn
08a8d93c T __pcap_atoin
08a8dbf8 T __pcap_nametodn addr
08a80034 T __program_heade r_table
08ab21f8 D blocks
08a84aa0 T bpf_dump
08a85d00 T bpf_error
08a84bd8 T bpf_filter
That translates to an 'extern' definition for 'blocks', and definitions
of the functions bpf_dump, bpf_error, bpf_filter .
With a program such as this available, it is relatively easy to write
a tool that will locate the definitions of each library, dump them
into a file, and then for each new library, cross-check in case it
defines something that is already present.
--
History is a pile of debris -- Laurie Anderson
Nov 15 '05 #2

Walter Roberson wrote:
In article <11************ **********@g47g 2000cwa.googleg roups.com>,

You mention the ADS arm toolkit but you do not happen to mention
which platform you are running on.
It is an embedded system based on the Arm PXA255.

As a generalization, unix-like platforms often provide tools such as
'nm' which can be used to ask a library for a list of symbols that it
defines.

ADS tools have a similar feature where I can have a list of the library

symbol table and other information.

With a program such as this available, it is relatively easy to write
a tool that will locate the definitions of each library, dump them
into a file, and then for each new library, cross-check in case it
defines something that is already present.
--


Well... I thought about that and I agree with you, would not be hard to
create an application to do that, but would you agree with me that all
systems that use libraries are subject to this issue ? And if this is
the
case I think ( but I might be wrong )this check should already be
available somewhere.

Thanks for your answer.

Nov 15 '05 #3


jo************* **@yahoo.com.br wrote:
Hello everybody,

Although I am sure this is an important question for this group, I
am not sure this question belongs to this group and I will be
happy to move it to the correct one after you point it to me.

Direct question:
How can I know if a function is defined in more than one static
library that I am using to link ?

More information:
We have a huge project with about 40 libraries, some of them are
third part libraries.
One day, when I got a new third part library release, I luckly
started getting a link error because a function called FileExists
was being defined in two libraries.
I said luckly because if I invert the order that the libraries are
being linked, I could not see the error and in that case who knows
what funcion was being used.
( of course I know, but it might be the wrong one and the problem
might showup two months from now and it must not show up )

The problem I am trying to avoid is: having two functions in two
different libraries with the same name, in this case, the function
that will be linked depend on the position of the libraries in the
link command.

I know that this is the beaulty of libraries, that we can override
functions, but I would like to be aware that this situation is
happening.

Also I know that is common sense that the libraries should have a
prefix in their name function, like the foo.lib should have
function names as foo_function1 or something like that, but this
is a convention and that can fail when using third part libraries.

Also can be argued that I should know the function names in the
libraries, but in this project we are talking about of thousands
of functions, lots of them are bought without source code, so it
is not pratical to do so, but even if this was pratical I would
like to have a computer checking to me.

I looked into my link for any option that would do that and I
could not find ( for references I use the ADS arm toolkit )

The ideal solution would be having a utility that will check the
libraries for me, or something else with the same idea.

I work in this area for many years and never thought about this
problem, until it bit me and know I think this is a problem that
could bite anyone, but I am not finding answers until now.

Please let me know if you need more information and any comments
are welcome.

Thanks in advance

Jose Luis Marchetti


I got a good answer ( worked ) from comp.sys.arm and I am bringing
it here:

Try linking all the objects from each library in a single link.
e.g.

armlink lib1.a(*.o) lib2.a(*.o) ...
If two functions with the same name exist, you should get multiple
definition errors.
Thanks!

Nov 15 '05 #4

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

Similar topics

4
1858
by: Dave Farrance | last post by:
What's the correct way to find the include directories and link libraries when compiling with gnu c++ ? I decided that I'd like to try out line-drawing using the GTK toolkit, so I copied the line drawing examples from this tutorial page: http://www.gtkmm.org/tutorial/sec-drawingarea.html I then tried to compile it with c++ on Mandrake Linux, and spent ages resolving the dependencies. I ran the compiler, looked at the first complaint...
2
3194
by: free2cric | last post by:
Hi, I have two c++ static libraries say A.lib and B.lib. I am creating third static library C I create project in microsoft visual studio as win32 static library. I go to project-> settings -> link , i dont find object/library module where I can type in the names of A.lib and b.lib.. this option is available if i create dynamic library. Thanks cric
1
2543
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. The solution also contains a project which includes all the above generated static libraries.I have set all the above projects as dependent projects in the 'Project Dependencies' option.
7
2625
by: Thiru | last post by:
I am writing an application that interacts with Oracle and Teradata. In order to create the executable, I need to link various Oracle and Teradata libraries. I found out that when I link the Oracle and Teradata libraries together, the Teradata API functions are not working properly. My assumption is that these libraries are sharing identical function names and parameter lists and hence the conflicts are causing the problem. Is my...
4
2958
by: Anthony Gallagher | last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to recompile one of our projects using VC++ .NET. I get all kind of linker errors (specially in STL calls). How do I get rid of these errors?? Anthony
2
9507
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how to do that? Thanks. Tsung-Yu
12
2298
by: Bonj | last post by:
can you embed a resource into a static libary? I'm using a custom binary resource specified as a .bin file in the .rc file of the static library project I've got. I use FindResource, LoadResource, LockResource to get the resource. However FindResource is returning null. If I use exactly the same code to retrieve a resource out of the resource of the console application used to test the static library, then it works perfectly. I can't see...
23
2032
by: Matt Silberstein | last post by:
Are there any good qualities libraries out there, free or for "reasonable" cost? -- Matt Silberstein Do something today about the Darfur Genocide http://www.beawitness.org
11
2214
by: Saurabh | last post by:
Hi all, I want to know why do we use libraries(static or shared). We can perform that work by including header files too.I also wish to know what exactly is linking and loading. i know these are pretty easy and basic questions. But plz help me considering the fact that i am a new developer in C++. Thanking you in advance.
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
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,...
1
10161
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
10000
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
9035
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
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
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
3720
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.