473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

library using library?

Hello,

I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images -
for that it uses "normal" jpeg-6b library. However, some functionality
is required that modifies the jpeg files as we need - this is the job of
the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f or
B::f gets called?

THANKS!

David
Nov 14 '05 #1
10 1587
Hello guys,

the problem can be also viewed as the following (more precisly):

an application must be linked with libraries A.lib and B.lib, both of
the libraries use their version of the JPEG library. I don't need to
expose the jpeg library to the application, so there does not have to be
collision A::f and B::f.

The problem is that when I compile library A and it calls functions from
the JPEG library, the final application that uses A must be linked with
the JPEG library. But the application itself does not care about
functions from the jpeg library, it only cares about functions from A.

Now, here's the problem. A and B use different JPEG libraries so we must
link the application with

A.lib A-jpeg.lib, B.lib, B-jpeg.lib

and that's it. A-jpeg.lib and B-jpeg.lib have the same interface but do
differ.

I would like to have only

A.lib, B.lib

and the internal - no needed - functionality of A-jpeg.lib and
B-jpeg.lib have inside them.

THANKS for comments!

David
Nov 14 '05 #2
David Soukal wrote:
Hello,

I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images -
for that it uses "normal" jpeg-6b library. However, some functionality
is required that modifies the jpeg files as we need - this is the job of
the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f or
B::f gets called?


You should look for (binary) tools/utilities to rename the library
routines to Af and Bf. Ask in a programming newsgroup for your specific
platform.

Kees

Nov 14 '05 #3
Hi,

but that's not very clean is it? I mean the source code for the A, B
libraries have hundreds of functions... To rename all of them to have
prexif "a" or "b" would be tedious, not mentioning the fact, that you
cannot UPGRADE A and B when a patch comes around...

Thanks,

D.
Case wrote:
David Soukal wrote:
Hello,

I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images
- for that it uses "normal" jpeg-6b library. However, some
functionality is required that modifies the jpeg files as we need -
this is the job of the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f
or B::f gets called?

You should look for (binary) tools/utilities to rename the library
routines to Af and Bf. Ask in a programming newsgroup for your specific
platform.

Kees

Nov 14 '05 #4
In <40**********@bingnews.binghamton.edu> David Soukal <ds******@binghamton.edu> writes:
I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images -
for that it uses "normal" jpeg-6b library. However, some functionality
is required that modifies the jpeg files as we need - this is the job of
the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f or
B::f gets called?


There is no general solution to your problem. On Unix systems, the first
library specified on the linking command always wins. On other systems,
the linker complains about multiply defined symbols.

And the C standard says that you're invoking undefined behaviour...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5
On Fri, 14 May 2004 08:34:09 -0400, David Soukal
<ds******@binghamton.edu> wrote:
Hello,

I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images -
for that it uses "normal" jpeg-6b library. However, some functionality
is required that modifies the jpeg files as we need - this is the job of
the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f or
B::f gets called?

THANKS!

David

There's no answer in standard C. You should ask in a forum dedicated
to the platform and tools you're using. You might be able to play some
(risky) games regarding linking order or something.. It doesn't help
after the fact, but namespaces in C are done by using a different
prefix for the external names of different libraries.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #6
Thank you guys,

this is what I though. Unfortunatelly, I *do* have to use the two
versions of the same library...

It's the IJG's JPEG library, it has dozens of functions, I don't want to
rename them mainly because of that I don't want to tie my hands for next
patches... I though about doing something like

jcmaster.c --> rename to jcmaster.c.old and creat

jcmaster.c as

namespace something {
#include "jcmaster.c.old"
}

and do that for all *.c files. But that's not really C solution and who
knows whether it would even compile on a C++ compiler...

Thanks again!

David

ps. I have no other choice, the first JPEG library is defined in
ImageMagick - I don't want to mess up that, and the other does what I
really need to do, modify some DCTs... something that does not belong to
ImageMagick :-(

pps. This only convinced me that C is really badly designed... :-) No
offense, to C lovers, please! God bless C++ namespaces or better yet
Java's packages... (only teasing)

Alan Balmer wrote:
On Fri, 14 May 2004 08:34:09 -0400, David Soukal
<ds******@binghamton.edu> wrote:

Hello,

I have an interesting problem that I'm tackling with. I'm sure there
must be some obvious solution...

I have this big project. It's composed of several *.lib modules. Now,
one of the modules uses IJG JPEG library. But, another module needs to
use *modified* verzion of the library: the application displays images -
for that it uses "normal" jpeg-6b library. However, some functionality
is required that modifies the jpeg files as we need - this is the job of
the other, modified, library.

Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions

from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?

Formally, it could be stated as,

an application must be linked with libraries A, B, both define a
function f(), how do I make sure that the proper function, i.e. A::f or
B::f gets called?

THANKS!

David


There's no answer in standard C. You should ask in a forum dedicated
to the platform and tools you're using. You might be able to play some
(risky) games regarding linking order or something.. It doesn't help
after the fact, but namespaces in C are done by using a different
prefix for the external names of different libraries.

Nov 14 '05 #7
ppps. :-)

On a more general note:

How do I write a (static) library A that uses a version of library C
(call it C1) and then write a library B that uses different version of
the library C (call it C2) *and* link library A, B to my application?

Since A, B use some functions from C1 and C2, I have to link the
application with C1 and C2 also, but there we go again...

At least with Microsoft C++, I cannot "include" C1 into A and C2 into
B... it's simply not possible for static libraries (am I wrong?).

I found this very odd since the application may not even care about
functions in C (C1, C2) so why do I have to link it with them...

Thanks for your thoughts!

David
Nov 14 '05 #8
In article <40**********@bingnews.binghamton.edu>, David Soukal
wrote:
Thank you guys,

this is what I though. Unfortunatelly, I *do* have to use the
two versions of the same library...
That sucks.
It's the IJG's JPEG library, it has dozens of functions, I
don't want to rename them mainly because of that I don't want
to tie my hands for next patches... I though about doing
something like

jcmaster.c --> rename to jcmaster.c.old and creat

jcmaster.c as

namespace something {
#include "jcmaster.c.old"
}

and do that for all *.c files. But that's not really C solution
and who knows whether it would even compile on a C++
compiler...

Thanks again!

David

ps. I have no other choice, the first JPEG library is defined
in ImageMagick - I don't want to mess up that, and the other
does what I really need to do, modify some DCTs... something
that does not belong to ImageMagick :-(

pps. This only convinced me that C is really badly designed...
:-) No offense, to C lovers, please! God bless C++ namespaces
or better yet Java's packages... (only teasing)


You need the help of IJG. There might be a solution built
into their headers that they can tell you about, or maybe they
can give you a back-port of the functionality you are missing.

--
Neil Cerutti
"The barbarian seated himself upon a stool at the wenches side, exposing
his body, naked save for a loin cloth brandishing a long steel broad
sword..." --The Eye of Argon
Nov 14 '05 #9
In <40**********@bingnews.binghamton.edu> David Soukal <ds******@binghamton.edu> writes:
On a more general note:

How do I write a (static) library A that uses a version of library C
(call it C1) and then write a library B that uses different version of
the library C (call it C2) *and* link library A, B to my application?


Which part of "undefined behaviour" in my previous post was too
difficult for you to understand?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #10
David Soukal <ds******@binghamton.edu> writes:
Now, when I link the application it crashes. After a few hours, we've
found out that it's because the code that should be calling functions
from B.jpeg6b in fact calls A.jpeg6b. The linker didn't even complain.

Now, since the IJG Jpeg-6b is in C not in C++, we cannot use
"namespace"s to seperate these two.

Has anybody met this problem before?


The jpeg library header files contain a set of macro definitions for
all the external function names, so you can change them in one place
(e.g. to add a version number suffix) and recompile the library.

--
Brian Gough

Network Theory Ltd,
Publishing Free Software Manuals --- http://www.network-theory.co.uk/
Nov 14 '05 #11

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

Similar topics

6
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
5
by: Venky | last post by:
We have a strange error here. We have an application that is built in VC++ 6.0 and uses a C library built using the same. Now, we have migrated to .Net and have used the same source code to be...
1
by: RTJ | last post by:
I have experienced problems with Oracle OCI library. I was unable to properly link OCI library using gcc. Probably gcc compiler provided with SFU is unable to link native Windows library. Oracle...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
4
by: Brian Shannon | last post by:
I am playing around with class libraries trying to understand how they work. I created a class library, library.vb. I placed the library.dll into the bin directory and set my reference. If I...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
4
by: Dave | last post by:
hi, I wrote class library that contain a struct stX and a new class library that get the first class library as referance and implement a function foo that one of its parametrs is of type of the...
0
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.