开发者

Naming conflicts between different libraries

I'm trying to compile my program with two statically linked libraries: SFML and PhysFS. However, at the linking phase I get the following errors:

eror LNK2005: _inflatePrime already defined in sfml-graphics-s.lib(inflate.obj)

error LNK2005: _inflateGetHeader already defined in sfml-graphics-s.lib(inflate.obj)

error LNK2005: _adler32_combine already defined in sfml-graphics-s.lib(adler32.obj)

error LNK2005: _crc32_combine already defined in sfml-graph开发者_如何学编程ics-s.lib(crc32.obj)

error LNK1169: one or more multiply defined symbols found

What should I do when two entirely unrelated libraries have this kind of conflicts?

Edit: Oh please-please tell me I'm not going to have to write a wrapper. I'm so tired of having to get things to work, I just want to write my own code already. :(


Both libraries seems to have preferred to include the zlib library instead of having a dependency on it. I'd try to build them without this inclusion and link the executable with zlib.


Assuming you have the library source code, this may be as simple as adding a couple of namespaces. In library A's header file:

namespace LibA {

   // existing function declarations

}

and in the C++ source files:

namespace LibA {

    // existing code

}

Same for library B, but with a different namespace name. I realise this is a pain, but if the libraries really do have name clashes, it is the cleanest approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜