库使用库? [英] library using library?

查看:63
本文介绍了库使用库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个有趣的问题,我正在解决。我很确定

必须是一个明显的解决方案...


我有这个大项目。它由几个* .lib模块组成。现在,

其中一个模块使用IJG JPEG库。但是,另一个模块需要

使用* modified * verzion of the library:应用程序显示图像 -

因为它使用正常 jpeg-6b库。但是,需要一些功能

来修改我们需要的jpeg文件 - 这是

另一个修改后的库的工作。

现在,当我链接应用程序时,它崩溃了。几个小时后,我们发现这是因为应该调用函数的代码
来自B.jpeg6b的
实际上是调用A.jpeg6b 。链接器甚至没有抱怨。


现在,由于IJG Jpeg-6b在C语言中不在C ++中,我们不能使用

" namespace"分开这两个。


以前是否有人遇到过这个问题?


正式的,可以说是,


应用程序必须与库A,B链接,两者都定义了一个

函数f(),如何确保正确的函数,即A :: f或者

B :: f被叫了?


感谢!


David

解决方案

大家好,


问题也可以看作如下(更精确):

应用程序必须与库A.lib和B.lib链接,这两个库都使用他们的JPEG库版本。我不需要

将jpeg库暴露给应用程序,所以不必将

碰撞A :: f和B :: f。


问题是,当我编译库A并且它从JPEG库中调用

的函数时,使用A的最终应用程序必须与

JPEG库。但是应用程序本身并不关心来自jpeg库的

函数,它只关心来自A的函数。


现在,这里是问题所在。 A和B使用不同的JPEG库,所以我们必须

链接应用程序


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


就是这样。 A-jpeg.lib和B-jpeg.lib有相同的界面但是

不同。


我想只有


A.lib,B.lib


和内部 - 不需要 - A-jpeg.lib的功能和

B -jpeg.lib里面有它们。


感谢您的评论!


David


< blockquote> David Soukal写道:

你好,

我有一个有趣的问题,我正在解决。我肯定有一些明显的解决方案......

我有这个大项目。它由几个* .lib模块组成。现在,
其中一个模块使用IJG JPEG库。但是,另一个模块需要使用库的* modified * verzion:应用程序显示图像 -
因为它使用正常库。 jpeg-6b库。但是,需要一些功能来修改我们需要的jpeg文件 - 这是另一个修改过的库的工作。

现在,当我链接应用程序时它崩溃了。几个小时后,我们发现它是因为B.jpeg6b中应该调用函数的代码实际上是调用A.jpeg6b。链接器甚至没有抱怨。

现在,由于IJG Jpeg-6b在C语言中不在C ++中,我们不能使用
namespace来分隔这两个。

以前是否有人遇到过这个问题?

正式地说,它可以说是,

一个应用程序必须与库A,B链接定义一个函数f(),如何确保正确的函数,即A :: f或
B :: f被调用?




您应该寻找(二进制)工具/实用程序来重命名库

例程到Af和Bf。在编程新闻组中询问您的特定

平台。


Kees





但这不是很干净吗?我的意思是A,B

库的源代码有数百个函数...要将它们全部重命名为

prexif" a"或b或b。将是乏味的,没有提到这样的事实,即当补丁到来时你不能升级A和B ......


谢谢,


D.

Case写道:

David Soukal写道:

你好,

我有一个有趣的问题,我正在解决。我肯定有一些明显的解决方案......

我有这个大项目。它由几个* .lib模块组成。现在,
其中一个模块使用IJG JPEG库。但是,另一个模块需要使用库的* modified * verzion:应用程序显示图像
- 因为它使用正常图像。 jpeg-6b库。但是,需要一些功能来修改我们需要的jpeg文件 -
这是另一个修改过的库的工作。

现在,当我链接应用程序时它崩溃了。几个小时后,我们发现它是因为B.jpeg6b中应该调用函数的代码实际上是调用A.jpeg6b。链接器甚至没有抱怨。

现在,由于IJG Jpeg-6b在C语言中不在C ++中,我们不能使用
namespace来分隔这两个。

以前是否有人遇到过这个问题?

正式地说,它可以说是,

一个应用程序必须与库A,B链接定义一个函数f(),如何确保正确的函数,即A :: f
或B :: f被调用?



您应该寻找(二进制)工具/实用程序来将库
例程重命名为Af和Bf。在编程新闻组中询问您的具体
平台。

基斯



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

解决方案

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


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


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



这篇关于库使用库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆