Code Monkey home page Code Monkey logo

Comments (8)

twall avatar twall commented on September 13, 2024

Function names are case sensitive.

On Apr 3, 2012, at 11:33 AM, write2warriors wrote:

Hi, I am getting the following error. Please help.
java.lang.UnsatisfiedLinkError: Error looking up function 'funcA': The specified procedure could not be found.

Am I doing something wrong?

Using the Dependency Walker, it shows MY.DLL has the following dependency and functions:

MY.DLL has a dependency on Kernel32.DLL. Kernel32.DLL has a dependency on NTDLL.DLL

functions:
class SomeClass & SomeClass::operator=(class SomeClass const &)
void FuncA(unsigned short,unsigned char *,unsigned char *)
int FuncB(unsigned char *,unsigned char *)

My JNA interface:

public interface MyDll extends Library {
void funcA(short len, char[] input, char[] output);
int funcB(char[] input, char[] output);
}

Calling:
char[] input = new char[] { [char array initialization] };
char[] output = new char[8]; // output has no more than 8 characters

MyDll myDll = (MyDll) Native.loadLibrary("C:[some path]\my.dll", My.class);
myDll.ecrMac(input, output);

The library is loaded, but why am I getting the error
java.lang.UnsatisfiedLinkError: Error looking up function 'funcA': The specified procedure could not be found.


Reply to this email directly or view it on GitHub:
#65

from jna.

write2warriors avatar write2warriors commented on September 13, 2024

It was a typo in this report. The function names are the same as the ones shown in Dependency Walker

from jna.

write2warriors avatar write2warriors commented on September 13, 2024

let me retype this. I apologize for the typo.

Using the Dependency Walker, it shows MY.DLL has the following dependency and functions:

MY.DLL has a dependency on Kernel32.DLL. Kernel32.DLL has a dependency on NTDLL.DLL

functions:
class SomeClass & SomeClass::operator=(class SomeClass const &)
void FuncA(unsigned short,unsigned char *,unsigned char *)
int FuncB(unsigned char *,unsigned char *)

My JNA interface:

public interface MyDll extends Library {

void FuncA(short len, char[] input, char[] output);
int FuncB(char[] input, char[] output);
}

Calling:
char[] input = new char[] { [char array initialization] };
char[] output = new char[8]; // output has no more than 8 characters

MyDll myDll = (MyDll) Native.loadLibrary("C:[some path]\my.dll", My.class);
myDll.FuncB(input, output);

The library is loaded, but why am I getting the error
java.lang.UnsatisfiedLinkError: Error looking up function 'FuncA': The specified procedure could not be found.

Do I need to have an interface for the overloading operator=? It's something I don't need. If so, how?

from jna.

twall avatar twall commented on September 13, 2024

Does dependency walker show those function names exported exactly as "FuncA" and "FuncB"?

If you are using a C++ compiler, you must use 'extern "C"' in order to avoid name mangling; stdcall calling convention will also add a suffix to function names.

On Apr 3, 2012, at 7:04 PM, write2warriors wrote:

let me retype this. I apologize for the typo.

Using the Dependency Walker, it shows MY.DLL has the following dependency and functions:

MY.DLL has a dependency on Kernel32.DLL. Kernel32.DLL has a dependency on NTDLL.DLL

functions:
class SomeClass & SomeClass::operator=(class SomeClass const &)
void FuncA(unsigned short,unsigned char *,unsigned char *)
int FuncB(unsigned char *,unsigned char *)

My JNA interface:

public interface MyDll extends Library {

void FuncA(short len, char[] input, char[] output);
int FuncB(char[] input, char[] output);
}

Calling:
char[] input = new char[] { [char array initialization] };
char[] output = new char[8]; // output has no more than 8 characters

MyDll myDll = (MyDll) Native.loadLibrary("C:[some path]\my.dll", My.class);
myDll.FuncA(input, output);

The library is loaded, but why am I getting the error
java.lang.UnsatisfiedLinkError: Error looking up function 'FuncA': The specified procedure could not be found.


Reply to this email directly or view it on GitHub:
#65 (comment)

from jna.

write2warriors avatar write2warriors commented on September 13, 2024

yes, dependency walker shows the following in the function column:

class SomeClass & SomeClass::operator=(class SomeClass const &)
void FuncA(unsigned short,unsigned char *,unsigned char *)
int FuncB(unsigned char *,unsigned char *)

Let me check with the one who wrote the DLL to see if they used 'extern "C"'.

Will update this as soon as I hear from them

from jna.

write2warriors avatar write2warriors commented on September 13, 2024

not sure if it answers your questions, but on Dedendency Walker,

Without undecorate C++ functions, it has:

??4SomeClass@@QAEAAV0@ABV0@@z
?FuncA@@YAXGPAE0@Z
?FuncB@@YAHPAE0@Z

With undecorate C++ functions, it has:

class SomeClass & SomeClass::operator=(class SomeClass const &)
void FuncA(unsigned short,unsigned char *,unsigned char *)
int FuncB(unsigned char *,unsigned char *)

I'm waiting for the DLL writer's reply, and will update this as soon as I hear from them.

from jna.

write2warriors avatar write2warriors commented on September 13, 2024

Update: The DLL is updated. now I am not getting the error anymore, but I am not getting any output.

dll exported function: int FuncB(unsigned char_, unsigned char_)

java: int FuncB (char[] input, char[] output).

code:
char[] output = new char[8]; // output has no more than 8 characters
char[] input = new char { 'x', 'x', 'x' };
int len = FuncB (input, output);

After FuncB is executed, output is just a blank char array, is it the DLL issue or I don't have the signature mapping correctly?

from jna.

twall avatar twall commented on September 13, 2024

Native unsigned char maps to java byte.

Java char maps to native wchar_t.

On Apr 13, 2012, at 6:45 PM, write2warriors wrote:

Update: The DLL is updated. now I am not getting the error anymore, but I am not getting any output.

dll exported function: int FuncB(unsigned char_, unsigned char_)

java: int FuncB (char[] input, char[] output).

code:
char[] output = new char[8]; // output has no more than 8 characters
char[] input = new char { 'x', 'x', 'x' };
int len = FuncB (input, output);

After FuncB is executed, output is just a blank char array, is it the DLL issue or I don't have the signature mapping correctly?


Reply to this email directly or view it on GitHub:
#65 (comment)

from jna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.