SWIG CYGWIN DLL 链接
我正在尝试遵循位于此处的 SWIG Java 示例。本例使用cygwin进行编译。我想向编译器传递一个已编译的 dll、test.dll,而不是 C 源文件。 SWIG.org 示例使用 C 源代码。我尝试将 test.dll(编译的 C 源代码)和 example.dll 传递给第三个命令,但出现错误“test.dll:没有这样的文件或目录”。 SWIG.org 示例的第三个命令基于 example.c 创建 example.dll。如何创建 example.dll 以便它使用 test.dll 而不是 example.c?
有没有办法在此示例的上下文中实现此目的?
我的尝试没有 C 源代码,只有 dll:
$ swig -java 示例.i
$ gcc example_wrap.c -I/c/jdk1.6.0_30/include -I/c/jdk1.6.0_30/include/win32
$ gcc -shared example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o test.dll example.dll
SWIG.org 示例代码:
$ swig -java example.i
$ gcc **-c example.c** example_wrap.c -I/c/jdk1.3.1/include -I/c/jdk1.3.1/include/win32
$ gcc -shared example.o example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o example.dll
I'm trying to follow the SWIG Java example located here. This example uses cygwin for compilation. I would like to pass the compiler an alredy compiled dll, test.dll, instead of a C source file. The SWIG.org example uses C source. I attempted to pass the test.dll(compiled C source) and then example.dll to the 3rd command but I get an error "test.dll: no such file or directory". The SWIG.org example's 3rd command creates the example.dll based on example.c. How can I create example.dll so that it uses test.dll instead of example.c?
Is there a way to accomplish this within the context of this example?
My Attempt without C Source, just dll:
$ swig -java example.i
$ gcc example_wrap.c -I/c/jdk1.6.0_30/include -I/c/jdk1.6.0_30/include/win32
$ gcc -shared example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o test.dll example.dll
SWIG.org Example Code:
$ swig -java example.i
$ gcc **-c example.c** example_wrap.c -I/c/jdk1.3.1/include -I/c/jdk1.3.1/include/win32
$ gcc -shared example.o example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o example.dll
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
test.dll
传递给最后一个命令,该命令链接您的程序,而不是第二个命令,后者仅编译 example_wrap.c 源文件。 (-c
选项告诉 gcc 仅进行编译。)请注意,链接行上对象和 DLL 的顺序很重要。 DLL 应该位于使用它们的任何内容之后。
You need to pass
test.dll
to the last command, which links your program, rather than the second, which just compiles the example_wrap.c source file. (The-c
option tells gcc to compile only.)Note that the ordering of objects and DLLs on the link line is important. DLLs should come after anything that uses them.