【发布时间】:2018-05-10 01:20:49
【问题描述】:
我完成了我的 Checkers 游戏引擎的工作,并将使其与 CheckerBoard (http://www.fierz.ch/cbdeveloper.php) 兼容,并且它声明了这一点。
CheckerBoard 期望您的引擎编译为 dll 并位于 checkerboard.exe 的工作目录 - 或在路径中。一个引擎 必须支持 2 个必需的功能。 ...,您必须再提供 2 个 多版本支持的功能。所有人的调用约定 函数是 __stdcall()。
所需功能
当前的 CheckerBoard API(第 2 版)需要以下 2 个 功能:
int WINAPI getmove(int board[8][8], int color, double maxtime, char str[1024], int *playnow, int info, int moreinfo, struct CBmove *move); int WINAPI enginecommand(char command[256], char reply[1024]);
我的引擎包括上述两个功能,我已经完成了所有设置(代码),但我在将其编译为 dll 时遇到了麻烦,这是我尝试过的(使用 gcc)
gcc -c engine.c
gcc -shared -o engine.dll engine.o
它按预期创建 dll,但 dll 不导出任何函数(如预期)。
我用Dependency walker程序扫描engine.dll文件,发现dll导出函数
- _getmove@28
- _enginecommand@20
我扫描了 CheckerBoard 目录中的一个引擎,发现它们导出了以下函数:
- getmove
- 引擎命令
我无法弄清楚为什么我创建的 dll 导出方式不同,也许它得到了 与 WINAPI 有什么关系?。
有什么想法吗?
这就是它的样子
#define EXPORT __declspec(dllexport)
EXPORT int WINAPI getmove(int b[8][8], int color, double time, char str[1024], int *playnow, int info, int unused, struct CBmove *cbmove){
// ....
return 0;
}
EXPORT int WINAPI enginecommand (char str[256], char reply[1024]){
// ...
return 0;
}
我需要通过 dll 导出这两个函数。
【问题讨论】:
-
请编辑您的问题,提供一些minimal reproducible example,或至少在您的
engine.c中显示相关代码(和声明);显示声明和定义getmove等的行