0

I was learning JNI recently. I wrote a native method in a Java file, and got the header file after compiling the Java file with javah.exe. Then I wrote a .cpp file and compiled it to a .dll file with code::blocks. I ran the Java program but got an error: java error.

enter image description here

So I opened the .dll file using DLL Export Viewer, and found that the there was a "@8" suffix in function name. suffix @8. I thought this was the reason why my Java file could not run normally. So does anyone know how to remove the "@8" suffix in function name?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • why are you just cracking the own dll?? check if something when wrong in declaring the interfaces instead.. – ΦXocę 웃 Пepeúpa ツ Apr 16 '16 at 09:55
  • Show us the C++ source code. Most likely, you did something wrong with the calling convention of your `sayHello` function. It should be C-like (also called `cdecl`), not Pascal-like (also called `stdcall`). See http://stackoverflow.com/questions/20790001/jni-does-not-work-with-stdcall – Roland Illig Apr 16 '16 at 10:03
  • Yeah, I've checked the Java code, header file and cpp file for many times. I searched many information about this error before asking, and they said it is the function name resulting in the error but dit not give the solution. – Frank Zhang Apr 16 '16 at 10:15
  • @RolandIllig I've seen the link you give and it solves my problem perfectly. I am now studying the answers to this question . Thank you very much! – Frank Zhang Apr 16 '16 at 10:31

1 Answers1

0

If you compile with GCC, simply provide --kill-at and your problem will go way. For MSVC, se here.

Community
  • 1
  • 1
Michael-O
  • 18,123
  • 6
  • 55
  • 121