hello,everyone!
I have encountered a problem when i want to call a windows dll in linux by java program, pls help me !
For the absence of the C source code, i want to migrate the windows dll to the linux ,which is called by a java program, named getDecode.dll.
The following is my steps:
[root@CGSL-N31 wine]# winedump spec -I. getDecode.dll
Contents of getDecode.dll: 360530 bytes
1 named symbols in DLL, 1 total, 1 unique (ordinal base = 1)
Done dumping getDecode.dll
Export 1 - '_Java_com_zte_ums_zxnm01_zxss_toolkit_trace_common_getDecode_getH248BinDecode@28' ... [Not Found]
[root@CGSL-N31 wine]# winebuild --def -E getDecode.spec -o getDecode.def
[root@CGSL-N31 wine]# winegcc -I/home/wine/wine-1.1.32/include -I. -lgetDecode getDecode_main.c -o getDecode_main.so -D__WINESRC__ -L. -L/usr/local/lib -lwine -lwinecrt0 -shared -specs=./getDecode.spec
gcc: specs file malformed after 139 characters
winegcc: gcc failed
The following is the content of getDecode.spec file:
# Generated from getDecode.dll by winedump
1 stub _Java_com_zte_ums_zxnm01_zxss_toolkit_trace_common_getH248Decode_getH248BinDecode
The following is the content of getDecode_main.c file:
/*
* getDecode.dll
*
* Generated from getDecode.dll by winedump.
*
* DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!
*
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "getDecode_dll.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(getH248Decode);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
switch (fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/******************************************************************
* _Java_com_zte_ums_zxnm01_zxss_toolkit_trace_common_getH248Decode_getH248BinDecode@28 (GETH248DECODE.1)
*
*
*/
#if 0
__stdcall GETH248DECODE__Java_com_zte_ums_zxnm01_zxss_toolkit_trace_common_getH248Decode_getH248BinDecode()
{
/* @stub in .spec */
}
#endif
My question is :what's wrong i have made?why can't i succeed to do the winegcc?what is the proper way to get the .so file?thank you in advance,thank you!
for help:how to call a windows dll in linux by java program!
-
- Newbie
- Posts: 2
- Joined: Wed Feb 24, 2010 9:20 pm
waterson79 its not another interface for this by any chance.
http://www.erlang.org/project/megaco/index.html
If so don't bother messing around with the windows dll just port accross to native.
http://www.erlang.org/project/megaco/index.html
If so don't bother messing around with the windows dll just port accross to native.
-
- Newbie
- Posts: 2
- Joined: Wed Feb 24, 2010 9:20 pm
oiaohm, thank you for your reply, but I do not want a new package to deal with the H248 protocol, because the data from the network devices is not the standard H248 stream which has been transformed. The dll supplied by the network devices is to deal with this transform.
Thanks!
Thanks!
oiaohm wrote:waterson79 its not another interface for this by any chance.
http://www.erlang.org/project/megaco/index.html
If so don't bother messing around with the windows dll just port accross to native.
Re: for help:how to call a windows dll in linux by java prog
Simple answer: you can't.waterson79 wrote:how to call a windows dll in linux by java program!
A bit longer answer: you should never do such a stupid thing in the first place!
A long answer:
- You'll need an entire Wine to call even a single dll. Which means you'll have to run entire java under Wine.
- What an idiot uses java (a cross-platform language/environment) to call specific system libraries? Either do it the right way (with an extra class that wraps calls to a library, which in turn calls native libraries). Or throw away java and use something more appropriate like c/c++.