gpt4 book ai didi

c++ - 我应该按什么顺序构建我的 C++ 静态库

转载 作者:行者123 更新时间:2023-11-28 04:41:09 27 4
gpt4 key购买 nike

我有 3 个静态库 graphics.lib、graphics_opengl.lib 和 graphics_d3d.lib

来自 graphics.lib:

class DeviceInfo
{
public:
std::string name;
};

class GenericGraphicDevice
{
public:
// example function populating info_out with generic device information.
virtual void GetDeviceinfo( DeviceInfo &info_out );

//...
};

来自 graphics_opengl.lib:

class OpenGLDeviceInfo : public DeviceInfo
{
public:
int gl_version;
};

class OpenGLGraphicDevice : public GenericGraphicDevice
{
public:
// example function populating info_out with gl specific device info and
// probably calling the base function it overrides to pick up the generic data.
virtual void GetDeviceInfo( DeviceInfo &info_out );

//...
};

与上面的 graphics_d3d.lib 设置相同。

所以我在我的 Visual Studio 解决方案中打开了 4 个项目。 1 个用于游戏,然后 1 个用于每个库。

选项 1) 我在通用图形项目中引用了 d3d 和 opengl 项目,所以我的构建顺序是:

d3d OR opengl
Then graphics

选项 2)d3d 和 opengl 引用通用图形,所以我的构建顺序是:

graphics
d3d OR opengl

以我的思维方式,d3d 和 opengl 从图形继承对象,那么当图形尚未构建时它们如何正确编译/链接?

因此,我一直在使用选项 2 创建本地构建,但最近发现其他开发人员一直在使用选项 1。

任何澄清我的想法在这里是对还是错以及为什么,将不胜感激。

最佳答案

如果都是静态库,它们之间应该没有依赖关系。换句话说,他们都是独立的。这样,他们就可以并行构建。

“游戏”项目应该依赖于所有三个静态库,因此它将在所有库构建完成后构建。

关于c++ - 我应该按什么顺序构建我的 C++ 静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50176092/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com