我应该怎么做,如果两个库提供具有相同名称产生冲突的功能? [英] What should I do if two libraries provide a function with the same name generating a conflict?

查看:257
本文介绍了我应该怎么做,如果两个库提供具有相同名称产生冲突的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该怎么做,如果我有两个库提供的功能具有同等的名字呢?

What should I do if I have two libraries that provide functions with equivalent names?

推荐答案


  • 如果你控制一个或两个:编辑之一更改名称并重新编译或等价看到未知的答案,将工作的没有访问源$ C ​​$ C。

  • 如果你不控制其中任何一个你可以用其中的一个。这是编译的其他的(静态链接!)库,什么也不做,除了转口贸易原来所有的符号,除了违规之一,它是通过包装达到与备用名称。什么麻烦。

  • 以后添加:由于qeek说,他在谈论动态库,这些解决方案通过的费鲁吉欧 mouviciel 可能是最好的。 (我好像活在以前长天,当静态链接是默认的,它的颜色我的想法。)

  • If you control one or both: edit one to change the name and recompile Or equivalently see Ben and unknown's answers which will work without access to the source code.
  • If you don't control either of them you can wrap one of them up. That is compile another (statically linked!) library that does nothing except re-export all the symbols of the original except the offending one, which is reached through a wrapper with an alternate name. What a hassle.
  • Added later: Since qeek says he's talking about dynamic libraries, the solutions suggested by Ferruccio and mouviciel are probably best. (I seem to live in long ago days when static linkage was the default. It colors my thinking.)
  • 中肯的意见:通过出口我的意思是,使可见模块链接到该库---相当于在文件范围内的的extern 关键字。这是如何控制是操作系统和连接器有关。它是我的总是的要回去看看。

    Apropos the comments: By "export" I mean to make visible to modules linking to the library---equivalent to the extern keyword at file scope. How this is controlled is OS and linker dependent. And it is something I always have to look up.

    这篇关于我应该怎么做,如果两个库提供具有相同名称产生冲突的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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