使用MinGW为Windows构建Linux库

3

有一个适用于Linux的lib源代码和make脚本。 http://svn.gna.org/svn/pokersource/branches/poker-eval-java/。 我需要为Windows构建它。它应该是两个dll文件。主要的dll和第二个dll是jni-wrapper,用于从Java调用本地函数。 我已经使用以下命令在Linux下构建了它:

autoreconf --install
./configure --enable-java
make

它已经成功构建并运行良好。但现在我需要将其适配到Windows系统。 我已经使用GUI安装程序安装了MinGW,并将mingw \ bin添加到我的PATH中。 我运行相同的命令,但在make时出现错误:

mv -f .deps/libpoker_eval_la-deck_std.Tpo .deps/libpoker_eval_la-deck_std.Plo
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../inclu
de -I../include  -Wall -Wpointer-arith -Wstrict-prototypes  -g -O2 -MT libpoker_
eval_la-enumerate.lo -MD -MP -MF .deps/libpoker_eval_la-enumerate.Tpo -c -o libp
oker_eval_la-enumerate.lo `test -f 'enumerate.c' || echo './'`enumerate.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -I../include -Wall -Wpoi
nter-arith -Wstrict-prototypes -g -O2 -MT libpoker_eval_la-enumerate.lo -MD -MP
-MF .deps/libpoker_eval_la-enumerate.Tpo -c enumerate.c  -DDLL_EXPORT -DPIC -o .
libs/libpoker_eval_la-enumerate.o
enumerate.c: In function 'enumExhaustive':
enumerate.c:415:5: error: 'intptr_t' undeclared (first use in this function)
enumerate.c:415:5: note: each undeclared identifier is reported only once for ea
ch function it appears in
make[1]: *** [libpoker_eval_la-enumerate.lo] Error 1
make[1]: Leaving directory `/drive/eval/lib'
make: *** [all-recursive] Error 1

完整的控制台日志在这里 http://dl.dropbox.com/u/12053587/mylog.txt

你能帮我解决这个问题吗? 谢谢


你使用的是哪个版本的Mingw-g++? - smerlin
这与Java有什么关系? - Peter Lawrey
这是一个带有DLL包装器的本地库,用于Java Native Interface。我可以使用Cygwin在Windows上构建它。但它不起作用,会导致JVM崩溃。 - NullPointer
如何查找mingw-g++版本?$ gcc --version gcc.exe(GCC)4.5.2 版权所有(C)2010自由软件基金会。 这是免费软件;请参阅源代码以获取复制条件。没有保证;甚至没有适用于特定目的的适销性保证。 - NullPointer
1个回答

2

你需要加入以下内容:

#include <stdint.h>

在enumerate.c文件中添加这一行代码可以解决此错误,但很可能需要在多个文件中添加此行代码。

也许它可以解决这个问题。但是我在我的Ubuntu上构建了它,没有做任何更改,并且在那里它可以正常工作。我也用cygwin为windows构建了它。同样,在那里也没有错误。但是当我从java在windows上使用它时,JVM总是崩溃。有些人说cygwin出了问题,他们使用这个库时也遇到了同样的问题。但是他们用mingw构建它就可以了! - NullPointer
C++标准并未明确规定哪些标准头文件必须或者不得被其他标准头文件包含。所以很可能在Ubuntu上,一些其他已包含的标准头文件中包含了stdint.h,而在Windows上没有。因此,只需手动包含它即可。 - smerlin
@NullPointer,很有可能配置脚本在你使用的mingw环境中执行时无法正确确定何时/何处需要“#include <stdint.h>”。 - Anya Shenanigans
谢谢你的帮助!我添加了#include <stdint.h>,现在一切都很好! - NullPointer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接