0

所以我很确定我的设计/设置有问题。但基本上在visual studio中,我想创建一个松散包装第三方代码的.lib项目,这部分很简单。

但是我发现当我在我的其他项目中使用 lib 时(在这种情况下是一个 dll,很容易成为不同项目中的一个 exe 等),dll 项目抱怨它需要与 lib 项目相同的包含目录. 这似乎......没有帮助。我有点明白为什么它会显示该消息,因为我包含了我的库中的标头,这反过来又包含了第 3 方包含文件...

有没有更好的设计建议?或者在visual studio中链接2个项目的更好方法。

我的消费者 dll,确实引用了我的 lib 的包含目录,并且我添加了项目作为参考,因此也应该设置 lib 输出。

帮助形象化

第 3 方代码 -> 我的包装器库 -> 我的 dll 使用者。

看起来我的消费者代码是否应该包含与我的包装器项目要抽象掉的相同的头文件。

4

1 回答 1

0

I am including a header from my lib, that is in turn including the 3rd party include file...

This is the problem, of course it will need that header if you are trying to include that header, whether directly or indirectly through another header.

You should produce a new header for the user of your lib that contains only the functions you are exposing to the user, and that doesn't include any other functions or other headers for the internal functions you are trying to wrap. The user of your lib can then just include this header, which will contain all the definitions they need.

于 2017-09-15T14:50:58.897 回答