1

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, which uses another .lib & .dll?

1
  • Are you really linking with the other .lib? Commented Jun 7, 2011 at 5:10

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.