2

I have met with LNK2019 error. The details are

error LNK2019: unresolved external symbol imp__JAWT_GetAWT@8 referenced in function "struct HWND * cdecl getHwndFromComponent(class jobject *,struct JNIEnv *)" (?getHwndFromComponent@@YAPAUHWND@@PAV_jobject@@PAUJNIEnv_@@@Z)

What I am building is a Win32 Console Application in DLL type.

I have included jawt_md.h. At first, I think it is the problem of 64 bit Java, so I have done things below:

1, Install a 32 bit java

2, Add C:\Program Files (x86)\Java\jdk1.6.0_45\include\win32; to Additional Include Directories.

3, Make sure the java be called in OS level is in C:\Program Files (x86)\Java\jdk1.6.0_45\bin. (Use java -version to test it)

However, I still meet the same issue when building the project.

Thanks for your help in advance.

Eugene
  • 10,627
  • 5
  • 49
  • 67
  • There will be a .lib file or a .dll providing the functions defined in `jawt_md.h`. You will have to specify the .lib library file and its path to the linker or add code to load the DLL. – user4581301 Sep 01 '16 at 09:05
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – user4581301 Sep 01 '16 at 09:08
  • undefined reference/unresolved external symbol is singlehandedly the worst error you can ever achieve -> A linkage error. C++ Doesn't even give you a detailed reason as to why. Usually it has to do with the following things: You haven't included the file in your includes, or your computer is missing a library you are trying to use. – Noam Rodrik Sep 01 '16 at 09:11
  • @user4581301. Thanks. It helps. – Eugene Sep 01 '16 at 09:16
  • 1
    @NoamRodrik Thanks for your detailed explanation – Eugene Sep 01 '16 at 09:17

1 Answers1

0

JAWT is a shared library, which means you need to link with it.

Try this:

  1. add C:\Program Files (x86)\Java\jdk1.6.0_45\lib as an additional library path (under linker settings)

  2. add jawt as an additional library (under linker settings)

rustyx
  • 80,671
  • 25
  • 200
  • 267