I have a compiled DLL (C/C++) and I have to use it in Java. So I want to use SWIG to create a wrapper . I followed all the tutorials like:
- How to create a DLL with SWIG from Visual Studio 2010
- http://www.swig.org/Doc3.0/Java.html
- SWIG JNI Interface with DLL and declarations only
But in all the examples no precompiled DLL and/or Java and/or Visual Studio (2015) were used. When using an own cpp file for the implementation (and don't use an external DLL, implementing the header) everything works fine (compile to a single DLL and calling from Java).
So what do I want: Having a precompiled DLL (example.dll), the header for that (example.h) and the SWIG header file (example.i). Compile everything to a "wrapper DLL", load this one in Java and accessing the precompiled DLL (example.dll).
My steps in detail:
- New VS class library project
- Add the h and i file
- Add the custom build step for the i file (like in the example)
- Java files and the example_wrap.cxx file is generated
- Add the example_wrap.cxx, add Java includes and don't use precompiled headers
- Compile example_wrap.cxx to example.lib (Is that right?)
- Setting project settings like in the tutorials (no clr, add java-includes, no precompiled headers)
- Now creating the whole project fails with linking error LNK2019 in example_wrap.obj.
Can someone help me?
What I also don't get: The result will be "example.dll". I have to use this DLL in Java (with System.load/loadLibrary). How can this SWIG DLL access the "original" example.dll with all the logic inside?
Using Python instead of Java results in the same failure (LNK2019 - unresolved external symbol).