www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Help with creating DLL

reply Dean Butler <butlerde us.ibm.com> writes:
Help!

I'm a newbie to DM and not deep on the Windows environment. I'm running
DM830 on Windows 2000. I'm trying to create a DLL for a C program that
will be called by a Java program using JNI.

When I try to compile and link (sc HelloJNI.c -WD) I see the following:

link HelloJNI,,,,HelloJNI/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

c:\program files\dm\bin\..\lib\SNN.lib(fplock)
 Error 42: Symbol Undefined _GetCurrentThreadId 0
c:\program files\dm\bin\..\lib\SNN.lib(write)
 Error 42: Symbol Undefined _GlobalFree 4
c:\program files\dm\bin\..\lib\SNN.lib(write)
 Error 42: Symbol Undefined _WriteFile 20
c:\program files\dm\bin\..\lib\SNN.lib(write)
 Error 42: Symbol Undefined _GlobalAlloc 8
c:\program files\dm\bin\..\lib\SNN.lib(write)
 Error 42: Symbol Undefined _SetFilePointer 16
c:\program files\dm\bin\..\lib\SNN.lib(io)
 Error 42: Symbol Undefined _GetStdHandle 4
c:\program files\dm\bin\..\lib\SNN.lib(io)
 Error 42: Symbol Undefined _SetHandleCount 4
c:\program files\dm\bin\..\lib\SNN.lib(io)
 Error 42: Symbol Undefined _DeleteFileA 4
c:\program files\dm\bin\..\lib\SNN.lib(io)
 Error 42: Symbol Undefined _CloseHandle 4
c:\program files\dm\bin\..\lib\SNN.lib(semlock)
 Error 42: Symbol Undefined _ReleaseSemaphore 12
c:\program files\dm\bin\..\lib\SNN.lib(semlock)
 Error 42: Symbol Undefined _CreateSemaphoreA 16
c:\program files\dm\bin\..\lib\SNN.lib(semlock)
 Error 42: Symbol Undefined _WaitForSingleObject 8
c:\program files\dm\bin\..\lib\SNN.lib(wctomb)
 Error 42: Symbol Undefined _WideCharToMultiByte 32
c:\program files\dm\bin\..\lib\SNN.lib(ISMBDIGI)
 Error 42: Symbol Undefined _GetStringTypeA 20
c:\program files\dm\bin\..\lib\SNN.lib(setnterr)
 Error 42: Symbol Undefined _GetLastError 0
c:\program files\dm\bin\..\lib\SNN.lib(_exit)
 Error 42: Symbol Undefined _ExitProcess 4
c:\program files\dm\bin\..\lib\SNN.lib(w32fater)
 Error 42: Symbol Undefined _WriteConsoleA 20
c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
 Error 42: Symbol Undefined _GetACP 0
c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
 Error 42: Symbol Undefined _GetOEMCP 0
c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
 Error 42: Symbol Undefined _GetCPInfo 8
c:\program files\dm\bin\..\lib\SNN.lib(cinit)
 Error 42: Symbol Undefined _GetEnvironmentStrings 0
c:\program files\dm\bin\..\lib\SNN.lib(cinit)
 Error 42: Symbol Undefined _GetVersion 0
c:\program files\dm\bin\..\lib\SNN.lib(cinit)
 Error 42: Symbol Undefined _FreeEnvironmentStringsA 4
c:\program files\dm\bin\..\lib\SNN.lib(read)
 Error 42: Symbol Undefined _ReadFile 20
c:\program files\dm\bin\..\lib\SNN.lib(isatty)
 Error 42: Symbol Undefined _GetFileType 4
c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
 Error 42: Symbol Undefined _VirtualFree 12
c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
 Error 42: Symbol Undefined _VirtualAlloc 16

--- errorlevel 27

What am I doing wrong?
    Dean
Nov 19 2002
parent reply rado <rpaskalev cofief.bg> writes:
add kernel32 to link list e.g.
link HelloJNI,,kernel32,,HelloJNI/noi;

but it will be esear for you if you do compile and link at one pass e.g.
dmc -oHelloJNI.dll HelloJNI.c

just give everithing to dmc and let it figure out what to do

rado

0 Tue, 19 Nov 2002 15:57:19 +0000, Dean Butler <butlerde us.ibm.com> ?8H5:
 Help!
 
 I'm a newbie to DM and not deep on the Windows environment. I'm running
 DM830 on Windows 2000. I'm trying to create a DLL for a C program that
 will be called by a Java program using JNI.
 
 When I try to compile and link (sc HelloJNI.c -WD) I see the following:
 
 link HelloJNI,,,,HelloJNI/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
 
 c:\program files\dm\bin\..\lib\SNN.lib(fplock)
  Error 42: Symbol Undefined _GetCurrentThreadId 0
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalFree 4
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _WriteFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalAlloc 8
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _SetFilePointer 16
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _GetStdHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _SetHandleCount 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _DeleteFileA 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _CloseHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _ReleaseSemaphore 12
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _CreateSemaphoreA 16
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _WaitForSingleObject 8
 c:\program files\dm\bin\..\lib\SNN.lib(wctomb)
  Error 42: Symbol Undefined _WideCharToMultiByte 32
 c:\program files\dm\bin\..\lib\SNN.lib(ISMBDIGI)
  Error 42: Symbol Undefined _GetStringTypeA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setnterr)
  Error 42: Symbol Undefined _GetLastError 0
 c:\program files\dm\bin\..\lib\SNN.lib(_exit)
  Error 42: Symbol Undefined _ExitProcess 4
 c:\program files\dm\bin\..\lib\SNN.lib(w32fater)
  Error 42: Symbol Undefined _WriteConsoleA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetACP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetOEMCP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetCPInfo 8
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetEnvironmentStrings 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetVersion 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _FreeEnvironmentStringsA 4
 c:\program files\dm\bin\..\lib\SNN.lib(read)
  Error 42: Symbol Undefined _ReadFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(isatty)
  Error 42: Symbol Undefined _GetFileType 4
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualFree 12
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualAlloc 16
 
 --- errorlevel 27
 
 What am I doing wrong?
     Dean
 
Nov 20 2002
parent reply Dean Butler <butlerde us.ibm.com> writes:
Attempted both suggestions listed below (added the -WD option to tell dmc to
create a DLL) but got the same error messages.

Is there something I may be missing in my configuration? Is there anything
required in the C file?

rado wrote:

 add kernel32 to link list e.g.
 link HelloJNI,,kernel32,,HelloJNI/noi;

 but it will be esear for you if you do compile and link at one pass e.g.
 dmc -oHelloJNI.dll HelloJNI.c

 just give everithing to dmc and let it figure out what to do

 rado

 0 Tue, 19 Nov 2002 15:57:19 +0000, Dean Butler <butlerde us.ibm.com> ?8H5:
 Help!

 I'm a newbie to DM and not deep on the Windows environment. I'm running
 DM830 on Windows 2000. I'm trying to create a DLL for a C program that
 will be called by a Java program using JNI.

 When I try to compile and link (sc HelloJNI.c -WD) I see the following:

 link HelloJNI,,,,HelloJNI/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 c:\program files\dm\bin\..\lib\SNN.lib(fplock)
  Error 42: Symbol Undefined _GetCurrentThreadId 0
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalFree 4
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _WriteFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalAlloc 8
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _SetFilePointer 16
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _GetStdHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _SetHandleCount 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _DeleteFileA 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _CloseHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _ReleaseSemaphore 12
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _CreateSemaphoreA 16
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _WaitForSingleObject 8
 c:\program files\dm\bin\..\lib\SNN.lib(wctomb)
  Error 42: Symbol Undefined _WideCharToMultiByte 32
 c:\program files\dm\bin\..\lib\SNN.lib(ISMBDIGI)
  Error 42: Symbol Undefined _GetStringTypeA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setnterr)
  Error 42: Symbol Undefined _GetLastError 0
 c:\program files\dm\bin\..\lib\SNN.lib(_exit)
  Error 42: Symbol Undefined _ExitProcess 4
 c:\program files\dm\bin\..\lib\SNN.lib(w32fater)
  Error 42: Symbol Undefined _WriteConsoleA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetACP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetOEMCP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetCPInfo 8
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetEnvironmentStrings 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetVersion 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _FreeEnvironmentStringsA 4
 c:\program files\dm\bin\..\lib\SNN.lib(read)
  Error 42: Symbol Undefined _ReadFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(isatty)
  Error 42: Symbol Undefined _GetFileType 4
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualFree 12
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualAlloc 16

 --- errorlevel 27

 What am I doing wrong?
     Dean
Nov 20 2002
parent rado <rpaskalev cofief.bg> writes:
this is strange

the first command i gave you is wrong ( i can never remember what comma for
what stands :)),  
but the second one should work as the kernel32.lib is added by default. 

Try to add kernel32.lib explicitly e.g.
dmc -oHelloJNI.dll HelloJNI.c kernel32.lib

If you want to use link command see
http://www.digitalmars.com/ctg/optlink.html#operational for explanation of
parameters.

regards
rado

0 Wed, 20 Nov 2002 12:09:53 +0000, Dean Butler <butlerde us.ibm.com> ?8H5:
 Attempted both suggestions listed below (added the -WD option to tell dmc to
 create a DLL) but got the same error messages.
 
 Is there something I may be missing in my configuration? Is there anything
 required in the C file?
 
 rado wrote:
 
 add kernel32 to link list e.g.
 link HelloJNI,,kernel32,,HelloJNI/noi;

 but it will be esear for you if you do compile and link at one pass e.g.
 dmc -oHelloJNI.dll HelloJNI.c

 just give everithing to dmc and let it figure out what to do

 rado

 0 Tue, 19 Nov 2002 15:57:19 +0000, Dean Butler <butlerde us.ibm.com> ?8H5:
 Help!

 I'm a newbie to DM and not deep on the Windows environment. I'm running
 DM830 on Windows 2000. I'm trying to create a DLL for a C program that
 will be called by a Java program using JNI.

 When I try to compile and link (sc HelloJNI.c -WD) I see the following:

 link HelloJNI,,,,HelloJNI/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 c:\program files\dm\bin\..\lib\SNN.lib(fplock)
  Error 42: Symbol Undefined _GetCurrentThreadId 0
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalFree 4
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _WriteFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _GlobalAlloc 8
 c:\program files\dm\bin\..\lib\SNN.lib(write)
  Error 42: Symbol Undefined _SetFilePointer 16
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _GetStdHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _SetHandleCount 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _DeleteFileA 4
 c:\program files\dm\bin\..\lib\SNN.lib(io)
  Error 42: Symbol Undefined _CloseHandle 4
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _ReleaseSemaphore 12
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _CreateSemaphoreA 16
 c:\program files\dm\bin\..\lib\SNN.lib(semlock)
  Error 42: Symbol Undefined _WaitForSingleObject 8
 c:\program files\dm\bin\..\lib\SNN.lib(wctomb)
  Error 42: Symbol Undefined _WideCharToMultiByte 32
 c:\program files\dm\bin\..\lib\SNN.lib(ISMBDIGI)
  Error 42: Symbol Undefined _GetStringTypeA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setnterr)
  Error 42: Symbol Undefined _GetLastError 0
 c:\program files\dm\bin\..\lib\SNN.lib(_exit)
  Error 42: Symbol Undefined _ExitProcess 4
 c:\program files\dm\bin\..\lib\SNN.lib(w32fater)
  Error 42: Symbol Undefined _WriteConsoleA 20
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetACP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetOEMCP 0
 c:\program files\dm\bin\..\lib\SNN.lib(setmbcp)
  Error 42: Symbol Undefined _GetCPInfo 8
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetEnvironmentStrings 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _GetVersion 0
 c:\program files\dm\bin\..\lib\SNN.lib(cinit)
  Error 42: Symbol Undefined _FreeEnvironmentStringsA 4
 c:\program files\dm\bin\..\lib\SNN.lib(read)
  Error 42: Symbol Undefined _ReadFile 20
 c:\program files\dm\bin\..\lib\SNN.lib(isatty)
  Error 42: Symbol Undefined _GetFileType 4
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualFree 12
 c:\program files\dm\bin\..\lib\SNN.lib(sbrk)
  Error 42: Symbol Undefined _VirtualAlloc 16

 --- errorlevel 27

 What am I doing wrong?
     Dean
Nov 20 2002