如何制作控制台 c++使用 pdCurses 便携式的文字游戏
嘿,我使用 pdCurses 库和微软操作系统工具制作了一个文本游戏,我想让它在任何计算机上运行。以下是我的包含:
#include <iostream>
#include <time.h> // or "ctime"
#include <stdio.h> // for
#include <cstdlib>
#include <Windows.h>
#include <conio.h>
#include<curses.h>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
#include <ctime>
#include <myStopwatch.h> // for keeping times
#include <myMath.h> // numb_digits() and digit_val();
myStopwath/Math.h 包含:
#include <stdio.h>
#include <math.h>
#include <tchar.h>
我是否需要像大多数可下载程序一样制作某种安装程序向导?我可以简单地将 dll、lib 和标头放入文件夹中吗?或者对于这样一个小程序有更简单的方法吗?谢谢! =)
顺便说一句:我想要做的就是向其他人展示我在另一台计算机上的游戏,而不是仅链接到这台计算机和 msVS++
Hey so i've made a text game using the pdCurses library and microsoft opperating system tools and i would like to make it work on any computer. Here are my includes:
#include <iostream>
#include <time.h> // or "ctime"
#include <stdio.h> // for
#include <cstdlib>
#include <Windows.h>
#include <conio.h>
#include<curses.h>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
#include <ctime>
#include <myStopwatch.h> // for keeping times
#include <myMath.h> // numb_digits() and digit_val();
myStopwath/Math.h includes:
#include <stdio.h>
#include <math.h>
#include <tchar.h>
Do i need to make some kind of installer wizard like most downloadable programs? Can i simply throw the dlls, libs, and headers in a folder? or is there a much simpler way for such a small program? Thanks! =)
BTW: all i want to be able to do is show someone my game from another computer, not being chained to this computer only and msVS++
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的评论,我想您想要......让我们称之为“可部署性”而不是可移植性,这通常是指跨不同平台运行程序的能力。
查看您的包含内容,保存 PDCurses 的所有内容都应包含在标准 Windows 安装中(尽管如果您使用特别新版本的 VC++ 编译器,则可能无法使其在旧版 Windows 上运行)。对于 PDCurses,如果它提供了 DLL,您可以将其与 .exe 并排放置,它应该可以工作。或者,研究静态链接,它将在可执行文件中嵌入库的副本。
为了百分百确定,您可以使用 Dependency Walker 来检查您的程序到底依赖于哪些 DLL,并与互联网并捆绑您需要的任何东西。
Based on your comment, I suppose you want... let's call it "deployability" rather portability, which usually refers to the ability to run a program across different platforms.
Looking at your includes, everything saves PDCurses should be included in a standard Windows install (although if you use a particularly new version of the VC++ compiler, you might not get it to work on older Windows). For PDCurses, if it provides its DLL, you can place it side by side with the .exe and it should work. Alternatively, look into static linking, which will embed a copy of the library inside your executable.
To be 100% sure, you can use Dependency Walker to check exactly which DLLs your program depend on, cross-check with the internet and bundle whatever you need.
使用 pdcurses 作为库是朝着正确方向迈出的一步,因为它是跨平台的。但是,
Windows.h
和conio.h
(及其关联的库)不是跨平台的。 conio 的大部分功能可能可以在 pdcurses 中找到。您是否可以在
Windows.h
中找到函数的兼容库将取决于您正在使用的函数以及您想要的目标平台。另一种选择是使用大量#ifdef
语句来包含每个平台所需的内容。其余的头文件是 C++ 或 C 标准库的一部分,因此它们应该是可移植的。
编辑:
感谢您澄清您的目标。我最初以为您想跨多个平台使用它。在您描述的情况下,您需要确保您拥有应用程序所需的所有 .dll,或者您已静态链接所有内容(另一个答案告诉您有关这两者的更多信息)。如有必要,请在虚拟机上测试您的程序和 dll,或者在另一个机器上测试干净的 Windows 安装。
Using pdcurses as your library is a step in the right direction, because it is cross-platform. However,
Windows.h
andconio.h
(and their associated libraries) are not cross-platform. Much of the functionality of conio can probably be found in pdcurses.Whether you can find compatible libraries for the functions in
Windows.h
will depend on what functions you are using and what platform you are looking to target. The other alternative is to use a host of#ifdef
statements to include what you need for each platform.The rest of those headers are a part of the C++ or the C standard libraries, so those should be portable.
Edit:
Thanks for clarifying your objective. I had initially thought you wanted to use it across multiple platforms. In the case that you describe, you need to make sure that you have all of the necessary .dlls with the application, or that you have linked everything statically (the other answer tells you a bit more about both of those). If necessary, test your program and dlls out on a virtual machine or a clean Windows install on another box.