1

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
Community
  • 1
  • 1
c12
  • 9,557
  • 48
  • 157
  • 253

1 Answers1

1

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.

ak2
  • 6,629
  • 31
  • 27
  • 1
    I tried $ gcc -shared example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o test.dll example.dll where test.dll is an anlready complied dll of my C libraries and example.dll is a new dll that communicates with it. I got a gcc: test.dll: No such file or directory. It should create the test.dll not want it as input, any ideas? – c12 Jan 07 '12 at 21:04