SWIG CYGWIN DLL链接 [英] SWIG CYGWIN DLL linking

查看:273
本文介绍了SWIG CYGWIN DLL链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按照这里的SWIG Java范例。这个例子使用cygwin进行编译。我想传递编译器一个alredy编译dll,test.dll,而不是一个C源文件。 SWIG.org示例使用C源。我试图传递test.dll(编译C源),然后example.dll到第三个命令,但我得到一个错误test.dll:没有这样的文件或目录。 SWIG.org示例的第3个命令基于example.c创建example.dll。如何创建example.dll,以便它使用test.dll而不是example.c?

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?

C Source,just dll:


$ swig -java example.i

$ swig -java example.i

$ gcc example_wrap.c -I / c / jdk1.6.0_30 / include -I / c / jdk1.6.0_30 / include / win32

$ 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

$ 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


推荐答案

您需要将 test.dll 传递给最后一个命令,该命令链接您的程序,而不是第二个命令,它只是编译了example_wrap.c源文件。 ( -c 选项指示gcc只能编译。)

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.)

请注意,对象和DLL在链接线很重要。 DLL应该在使用它们的任何东西之后。

Note that the ordering of objects and DLLs on the link line is important. DLLs should come after anything that uses them.

这篇关于SWIG CYGWIN DLL链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆