Java create .dll file
I want to create .dll with java jni. My .cpp file refers to an external .lib for a .dll . When I compile this file (with cl command) I get error:
LNK2019: unresolved external symbol "__declspec(dllimport) unsigned long __stdcall ConnectDevice(char const *, unsigned long)"
(__imp_?ConnectDevice@@YGKPBDK@Z)... fatal error LNK1120: 1 unresolved externals
Can I create .dll from .cpp开发者_StackOverflow社区, which uses another .lib & .dll?
Yes, you can. You can directly link to it, by putting this into one of your .c/.cpp files:
#pragma comment(lib,"libname")
or specifying the lib on the command line (unusual for MSVC), or in the IDE options.
What's more tricky is making sure that your DLL is found. If both DLL's are kept in the same folder, and SetDllDirectory() is not being used (unusual), then it should be found.
There are tools like Dependancy Walker (depends.exe) that helps solving such issues. Or Process Explorer (procexp) [please google] that can show for every process what DLL is loaded (ctrl+d there).
精彩评论