c12
c12

Reputation: 9827

Errors Creating A Shared Library DLL for SWIG Packaged Simple Java Example (Windows)

I've gone over the SWIG FAQ and dynamic module documentation and there seems to be a wide array of options when deciding on how to build the JNI shared library dll for Windows. The wiki describes the process using very old versions of visual c++. What is everyone using?

I've installed MinGW and the below commands on Windows 7 and ran the below commands on the SWIG simple java example, see below:

Last command errors out with:

example_wrap.o:example_wrap.c:(.text+0xa9): undefined reference to `gcd'
example_wrap.o:example_wrap.c:(.text+0xe2): undefined reference to `Foo'
example_wrap.o:example_wrap.c:(.text+0xe8): undefined reference to `Foo'
example_wrap.o:example_wrap.c:(.text+0x107): undefined reference to `Foo'
example_wrap.o:example_wrap.c:(.text+0x10d): undefined reference to `Foo'
collect2: ld returned 1 exit status

Upvotes: 1

Views: 1214

Answers (1)

It looks like you've either not compiled or not linked example.c, only example_wrap.c. You need to do something like:

swig -java example.i
gcc -c example_wrap.c -I somepath -I someotherpath
gcc -c example.c -I somepath -I someotherpath
gcc -shared example_wrap.o example.o -o example.dll

Upvotes: 2

Related Questions