hi:
I am sorry to disturb you with a question about calling PE Dll on linux. This is really an old question. I found the sameness issues in mail list.
http://www.winehq.org/pipermail/wine-devel/2003-December/thread.html http://www.winehq.org/pipermail/wine-devel/2005-November/thread.html#41917 http://www.winehq.org/pipermail/wine-users/2004-August/014685.html http://www.winehq.org/pipermail/wine-devel/2006-August/050619.html
I have tried the ways discussed in these threads。 But it's not clear enough how to do this. So I send this mail to you for some help.
I have a PE Dll named Arithmetic.dll which exports a function, it's prototype is: void sort(unsigned int*, int num)
I want to call the function in my Linux App.
I used winedump to generate a spec file
winedump spec Arithmetic.dll
This comand generated three files: Arithmetic_dll.h Arithmetic_main.c and Arithmeticspec. What's the next exactly step I should do? What's the usage of the three files? And wow could I use them?
I made reference to mplayer's implementation, It's code is a little clutter, and I don't have experience on MS D-Show. Could you give me some simple sample codes ??
Best Regards.
I have a PE Dll named Arithmetic.dll which exports a function, it's prototype is: void sort(unsigned int*, int num)
The easiest way would be to use LoadLibrary/GetProcAddress to load the function from the library. That way you avoid linking to it which makes things more complicated.
In order to be able to use wine functions you need to (re)compile parts of your program using Winelib (e.g. winegcc/wineg++). Your program will depend on Wine but you will be able to use the win32 dll.
Regards, Roderick Colenbrander
On 8/20/07, trulyliu trulyliu@gmail.com wrote:
hi:
I am sorry to disturb you with a question about calling PE Dll on linux. This is really an old question. I found the sameness issues in mail list.
http://www.winehq.org/pipermail/wine-devel/2003-December/thread.html http://www.winehq.org/pipermail/wine-devel/2005-November/thread.html#41917 http://www.winehq.org/pipermail/wine-users/2004-August/014685.html http://www.winehq.org/pipermail/wine-devel/2006-August/050619.html
I have tried the ways discussed in these threads。 But it's not clear enough how to do this. So I send this mail to you for some help.
I have a PE Dll named Arithmetic.dll which exports a function, it's prototype is: void sort(unsigned int*, int num)
I want to call the function in my Linux App.
You can't, it's not supported (yet), but what you want is the Wine plugin API (http://wiki.winehq.org/WinePluginApi).
At the moment you have 2 options: * Make a Windows application instead of a Linux application. * Make a winelib application which will require wine to run but can access Linux libraries as well (with some restrictions, eg. you have to use Windows synchronization primitives instead of the pthreads ones).
I used winedump to generate a spec file
winedump spec Arithmetic.dll
This comand generated three files: Arithmetic_dll.h Arithmetic_main.c and Arithmeticspec. What's the next exactly step I should do? What's the usage of the three files? And wow could I use them?
#include <windows.h>
int main(int argc, char **argv) { HANDLE h; void (/*WINAPI?*/ *sort)(unsigned int,int); unsigned int *nums = malloc(sizeof(unsigned int) * 4); nums[0] = 3; nums[1] = 2; nums[2] = 1; nums[3] = 0; h = LoadLibrary("Arithmetic.dll"); sort = GetProcAddress(h, "sort"); sort(nums, 4); }
winegcc main.c -o main ./main
I made reference to mplayer's implementation, It's code is a little clutter, and I don't have experience on MS D-Show. Could you give me some simple sample codes ??
MPlayer's code is GPL, so if you use it your code will be GPL too.
Best Regards.
-- trulyliu@gmail.com
Good luck Damjan
2007/8/20, Damjan Jovanovic damjan.jov@gmail.com:
On 8/20/07, trulyliu trulyliu@gmail.com wrote:
hi:
I am sorry to disturb you with a question about calling PE Dll on linux. This is really an old question. I found the sameness issues in mail list.
http://www.winehq.org/pipermail/wine-devel/2003-December/thread.html
http://www.winehq.org/pipermail/wine-devel/2005-November/thread.html#41917
http://www.winehq.org/pipermail/wine-users/2004-August/014685.html http://www.winehq.org/pipermail/wine-devel/2006-August/050619.html
I have tried the ways discussed in these threads。 But it's not clear enough how to do this. So I send this mail to you for some help.
I have a PE Dll named Arithmetic.dll which exports a function, it's prototype is: void sort(unsigned int*, int num)
I want to call the function in my Linux App.
You can't, it's not supported (yet), but what you want is the Wine plugin API (http://wiki.winehq.org/WinePluginApi).
At the moment you have 2 options:
- Make a Windows application instead of a Linux application.
- Make a winelib application which will require wine to run but can
access Linux libraries as well (with some restrictions, eg. you have to use Windows synchronization primitives instead of the pthreads ones).
I used winedump to generate a spec file
winedump spec Arithmetic.dll
This comand generated three files: Arithmetic_dll.h Arithmetic_main.c
and
Arithmeticspec. What's the next exactly step I should do? What's the usage of the three files? And wow could I use them?
#include <windows.h>
int main(int argc, char **argv) { HANDLE h; void (/*WINAPI?*/ *sort)(unsigned int,int); unsigned int *nums = malloc(sizeof(unsigned int) * 4); nums[0] = 3; nums[1] = 2; nums[2] = 1; nums[3] = 0; h = LoadLibrary("Arithmetic.dll"); sort = GetProcAddress(h, "sort"); sort(nums, 4); }
winegcc main.c -o main ./main
I have tried these code, It works well. Thanks a lot. Could I use gcc/g++ instead of winegcc/wineg++ ??? mplayer use gcc as it's complier? What's the mystery in it?
I made reference to mplayer's implementation, It's code is a little clutter, and I don't have experience on MS D-Show. Could you give me some simple sample codes ??
MPlayer's code is GPL, so if you use it your code will be GPL too.
Best Regards.
-- trulyliu@gmail.com
Good luck Damjan
trulyliu wrote:
I have tried these code, It works well. Thanks a lot. Could I use gcc/g++ instead of winegcc/wineg++ ??? mplayer use gcc as it's complier? What's the mystery in it?
AFAIK mplayer uses their own old version of wine they have adapted to mplayer.
regards, Jakob
On 8/21/07, trulyliu trulyliu@gmail.com wrote:
I have tried these code, It works well. Thanks a lot. Could I use gcc/g++ instead of winegcc/wineg++ ??? mplayer use gcc as it's complier? What's the mystery in it?
gcc/g++ would give you the wrong ABI (eg. 4 bytes per wide char instead of 2 bytes), and the special code needed to set up the Windows memory layout and the thread extension block and structured exception handling wouldn't get executed, leading to segfaults when you call any code that tries to access them. That's assuming you can even compile and link.
That's why you need winegcc/wineg++.
trulyliu@gmail.com
Damjan