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

Discussion in 'Java' started by Mary, Oct 11, 2004.

  1. Mary

    Mary Guest

    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>
    Mary, Oct 11, 2004
    #1
    1. Advertising

  2. Re: JNI problem - linkage problems trying to generate DLL for Win32functions...

    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
    Thomas Fritsch, Oct 11, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Dorris

    JNI linkage issue

    Thomas Dorris, Jan 31, 2004, in forum: Java
    Replies:
    2
    Views:
    3,051
    Thomas Dorris
    Feb 2, 2004
  2. vasanth
    Replies:
    0
    Views:
    2,663
    vasanth
    Jan 25, 2005
  3. vasanth
    Replies:
    0
    Views:
    610
    vasanth
    Jan 25, 2005
  4. pcarr01
    Replies:
    3
    Views:
    658
    Gordon Beaton
    Feb 17, 2005
  5. Replies:
    1
    Views:
    581
    Michael DOUBEZ
    Sep 12, 2008
Loading...

Share This Page