gpt4 book ai didi

java - 在 Windows 中将 SWIG 生成的文件构建到 DLL 中

转载 作者:行者123 更新时间:2023-11-30 17:19:14 24 4
gpt4 key购买 nike

我已经阅读了 swig 教程,它是这样做的:

$ swig -java example.i
$ gcc -c example_wrap.c -I/usr/java/include -I/usr/java/include/solaris
$ ld -G example_wrap.o -o libexample.so

我可以执行第一个命令,但接下来的两个命令无法执行,因为我没有 gcc,但是我有 Microsoft Visual Studio Express 2013,但我找不到任何使用 MSE2013 构建 dll 文件的教程。我正在运行 W7 64 位。而且我正在从 c++ 构建到 java。

有人知道如何生成库文件吗?所以我可以做

public class runme {
static {
System.loadLibrary("example");
}

public static void main(String argv[]) {
System.out.println(example.fact(4));
}
}

最佳答案

我通常构建 Python 包装器,但它应该是这样的:

cl /LD /Feexample.dll /IC:\jdk1.3\include /IC:\jdk1.3\include\win32 example_wrap.c

/LD 生成 DLL,/Fe 设置输出文件名,/I 添加包含路径。

还有:http://www.swig.org/Doc3.0/SWIGDocumentation.html#Java_visual_studio

关于java - 在 Windows 中将 SWIG 生成的文件构建到 DLL 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28926910/

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