Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JNI problem - linkage problems trying to generate DLL for Win32 functions...

Reply
Thread Tools

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

 
 
Mary
Guest
Posts: n/a
 
      10-11-2004
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>
 
Reply With Quote
 
 
 
 
Thomas Fritsch
Guest
Posts: n/a
 
      10-11-2004
Mary wrote:

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


--
Thomas<dot>Fritsch<squiggle>ops<dot>de

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ linkage vs c linkage ramasubramanian.rahul@gmail.com C++ 1 09-12-2008 11:41 AM
Second long argument to a JNI call on a Win32 DLL contains zero when it reaches the DLL pcarr01 Java 3 02-17-2005 09:30 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:03 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments