制作可重用的代码

发布于 2025-01-07 04:38:49 字数 839 浏览 2 评论 0原文

我已经用 C++ 编写了一个游戏引擎,但是我想将其打包在一个文件中,这样我就不必每次制作游戏时都重新编译它。我阅读了有关编写可重用代码并将其放入托管程序集或 .dll 中的 MSDN 文章。但据我所知,.dll 是个坏主意,而且很麻烦。我会做托管程序集,但是按照 MSDN 文章中描述的方法,他们似乎希望您将所有内容都放在一个类中或使用 CLR(或类似的东西)。在我的引擎中,我在不同的实例中采用了 C 方法,我不想只是为了打包而拆开引擎,另外我最终希望使其跨平台,所以我也不想让它变得跨平台“微软风格”。所以我想问题是:是否有一个好的替代方案可以替代 .dll 或托管程序集或我可以使用而无需分解我的代码的东西?

PS 我只会使用 .lib (静态库),但我相信它需要 .dll 才能运行。

信息:

  • 语言:C++。
  • 编译器、IDE、链接器等:Microsoft Visual C++ 2008。
  • 平台、操作系统等:Windows 7。
  • 应用程序中使用的库:SFML 1.6、Luabind、Lua C API。

来源:

I have written a game engine in C++, however I would like to package it up in a file so I don't have to re-compile it every time I want to make a game. I read the MSDN articles on writing re-usable code, and putting it into managed Assembly or in a .dll. But as I am told a .dll is a bad idea and a pain in the neck. I would do managed Assembly however the method of which you would do that as described in the MSDN article it looks like they want you to put everything in a class or use CLR (or something gross like that). In my engine I have taken a C approach at different instances and I don't want to rip apart the engine just to package it up, additionally I would eventually like to make it cross-platform so I don't want to make it too "Microsoftish". So I suppose the question is: is there a good alternative to a .dll or managed Assembly or something that I can use without ripping apart my code?

P.s I would just use a .lib (static library) but I believe it requires a .dll to run.

Info:

  • Language: C++.
  • Compiler, IDE, Linker ect: Microsoft Visual C++ 2008.
  • Platform, OS, ect: Windows 7.
  • Libraries Used In Application: SFML 1.6, Luabind, Lua C API.

Sources:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小ぇ时光︴ 2025-01-14 04:38:49

静态库(.lib)是最自然的懒惰选择。您将使用编译器对其进行一次编译,然后链接到程序的其余部分。如果您更改程序,但未更改引擎/库,则无需重新编译后者。当然,您需要使用您使用的每个编译器和每个操作系统来编译该库,除非它们兼容。

A static library (.lib) is the most natural lazy choice. You will compile it once with your compiler and then just link to the rest of your program. If you change the program, but not the engine/library, you don't recompile the latter. Of course, you'll need to compile the library with every compiler you use and for every OS, unless they are compatible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文