JNI problem - linkage problems trying to generate DLL for Win32 functions...

M

Mary

Hello,

The problem I am having is when I try to generate a dll from the
RegConnect.c code. The RegConnect.c class contains the JNI calls as
well as the calls to the Win32 registry functions, such as
RegCloseKey, RegDeleteKey etc. I just want to build the dll for this
class, so I can call the functions from my Java class. The problem is
when I try to use the command line to generate the dll, I get the
errors, listed below.
I initially thought this was because windows.h was included in the
RegConnect.c file and it wasn't on my machine. So I downloaded the
Windows SDK. This still didn't solve the problem. I then thought it
was because I wasn't including advapi32.lib but I have listed that as
one of the includes (maybe this is not how i should be doing it??) but
it still doesn't work.
I am using java.1.4.1 on Windows XP.
The environment variables I am using are:
WINDOWS_INCLUDE: "C:\Program Files\Microsoft SDK\include"
JAVA_INCLUDE: C:\j2sdk1.4.1_01\include
advapi32.lib is in the C:\Program Files\Microsoft SDK\lib directory.

I have been searching all the newsgroups but cannot find an exact
replicate of the problem as most others who have this problem are
using MSVC++ and can just update their project settings!

Thanks in advance for any help on this!

Mary


C:\Projects\PCF\src>cl -I%WINDOWS_INCLUDE% -I"C:\Program
Files\Microsoft SDK\lib
" -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -LD RegConnect.c
-FeRegConnect.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

RegConnect.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/dll
/implib:RegConnect.lib
/out:RegConnect.dll
RegConnect.obj
Creating library RegConnect.lib and object RegConnect.exp
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCloseKey@4
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegQueryValueE
xA@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegOpenKeyExA@
20
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegConnectRegi
stryA@12
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__wsprintfA
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegSetValueExA
@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCreateKeyEx
A@36
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegDeleteKeyA@
8
RegConnect.dll : fatal error LNK1120: 8 unresolved externals

C:\Projects\PCF\src>
 
T

Thomas Fritsch

Mary said:
Hello, Hello Mary!

The problem I am having is when I try to generate a dll from the
RegConnect.c code. The RegConnect.c class contains the JNI calls as
well as the calls to the Win32 registry functions, such as
RegCloseKey, RegDeleteKey etc. I just want to build the dll for this
class, so I can call the functions from my Java class. The problem is
when I try to use the command line to generate the dll, I get the
errors, listed below.
I initially thought this was because windows.h was included in the
RegConnect.c file and it wasn't on my machine. So I downloaded the
Windows SDK. This still didn't solve the problem. I then thought it
was because I wasn't including advapi32.lib but I have listed that as
one of the includes (maybe this is not how i should be doing it??) but
it still doesn't work.
I am using java.1.4.1 on Windows XP.
The environment variables I am using are:
WINDOWS_INCLUDE: "C:\Program Files\Microsoft SDK\include"
JAVA_INCLUDE: C:\j2sdk1.4.1_01\include
advapi32.lib is in the C:\Program Files\Microsoft SDK\lib directory.
....
C:\Projects\PCF\src>cl -I%WINDOWS_INCLUDE% -I"C:\Program
Files\Microsoft SDK\lib
" -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -LD RegConnect.c
-FeRegConnect.dll
May be you must give one further option to tell CL.EXE where to search
for the libraries. But I'm too little Windows-experienced to know
exactly how :-(

....
... unresolved external symbol __imp__RegCloseKey@4
... unresolved external symbol __imp__RegQueryValueExA@24
... unresolved external symbol __imp__RegOpenKeyExA@20
... unresolved external symbol __imp__RegConnectRegistryA@12
... unresolved external symbol __imp__wsprintfA
... unresolved external symbol __imp__RegSetValueExA@24
... unresolved external symbol __imp__RegCreateKeyExA@36
... unresolved external symbol __imp__RegDeleteKeyA@8
... 8 unresolved externals
Looking at this list of your unresolved externals and at the docu of
these functions, I very much assume that the import libraries Advapi.lib
(containing all the Reg* functions) and User32.lib (containing
wsprintfA) were not found by your linker.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top