Hi!
Sorry if this has been covered before, but I could not find any answers in the archives or by Googling...
Here's the situation: I have a Windows DLL and a small Windows program that calls functions from this DLL. The Windows program does not have a GUI (it's command-line based.) I have the C source code for this program, but don't have the source code for the DLL. I built the program with Visual C and was able to run it under WINE just fine with wcmd.
Now, I want to run this program natively under Linux - I mean, I don't want to run wcmd because that requires an X server.
The first question is: is this possible? (have a Unix program that calls functions from a native Windows DLL). I started experimenting with winelib, but am not sure if this is the correct way...
If this is possible, how should I do it? I ran winemaker, configure, make, but am getting errors from winbebuild.
Summarizing: I have the C source code. This C program calls function foo() that is in a Windows DLL. I want to run this program under Linux without the need for an X server. The program calls gets(), printf(), etc. I want these functions to be from my Linux's libc, not Windows'.
Any help will be greatly appreciated.
Thanks in advance!
Eloy.-
P.S. I read the winelib user guide, but couldn't find the answer there. If it is there, it's not clear to me :(
On Mon, 2003-04-14 at 09:09, Eloy A. Paris wrote:
Sorry if this has been covered before, but I could not find any answers in the archives or by Googling...
Yeah, I've been down that track recently myself! :)
Here's the situation: I have a Windows DLL and a small Windows program that calls functions from this DLL... Now, I want to run this program natively under Linux - I mean, I don't want to run wcmd because that requires an X server.
The first question is: is this possible? (have a Unix program that calls functions from a native Windows DLL).
It sure is possible!
I started experimenting with winelib, but am not sure if this is the correct way...
My (limited) experience suggests that using WineLib is the right way to accomplish what you want. There are other means, by which I mean that there are a number of open source projects which have hacked the Wine "loader" code: avifile; mplayer; xine, but they're most likely to work with DLLs which call only a finite subset of the Windows API.
If this is possible, how should I do it? I ran winemaker, configure, make, but am getting errors from winbebuild.
Hurdles I had to cross include:
1. I had built Wine below my home directory, but linking against it there produced unimpressive results. I suspect that Wine is highly critical of attempts to look for it's DLLs anywhere other than below /usr/lib/wine (or, perhaps, to be generous, /usr/local/lib/wine).
I got "sudo" permission from my sysadmin, installed Wine properly, and instantly had better success with WineLib.
2. Parameters to winemaker. Parameters to configure are easy (with a properly installed Wine), also for make. Because winebuild is called from make, we don't have much control over the parameters it sees. We've got to get the incantation to winemaker correct.
I eventually went for the minimalist approach:
--cuiexe --single-target foo.exe -L/home/kevin/lib
3. Code. When your "application" finally links, you'll see -lwine on the compiler command line. That's so that your application can call things like "LoadLibrary()" and "GetProcAddress()". I found the text in <wine-src-root-dir>/documentation/HOWTO-winelib to be confusing, but ultimately suggestive of the path to take.
What you *want* to do is to arrange for the following:
WINE ---loads--> foo.exe ---calls--> bar.DLL
What you *have* to do is subtly different:
WINE ---loads--> foo.exe ---runs--> stub ---loads--> bar.DLL
where it is suggested that "stub" be a "WineLib DLL", or, linked so as to be called "stub.dll.so". I eventually decided to go without the stub.dll.so, but only after deciding to achieve the same result by linking equivalent code into my application. I had problems in getting any WineLib DLL I produced to be correctly initialised, i.e., to have it's DllMain() executed implicitly at LoadLibrary() time. My way, I can control it explicily by making certain that my app call stub_init() explicitly.
The intention is that "stub" should shadow the APIs in bar.DLL through function pointers. Here's an example: bar.DLL exports a function called "int func(int)". That prototype would already be exposed by the fubar.h header file. You've basically got to write your own func(), like this. Code in stub.c will look like:
#include "fubar.h" #include <windows.h> static int (*func_pointer)(int);
void stub_init() { HINSTANCE handle = LoadLibrary("fubar.dll"); GetProcAddress(handle, "func", func_pointer); }
int func(int x) { return func_pointer(x); }
Do that, or something similar, and you'll soon be smiling.
P.S. I read the winelib user guide, but couldn't find the answer there. If it is there, it's not clear to me :(
Ha! I know exactly what you mean!
It seems the Wine project in general suffers from a distinct lack of good and relevant documentation. Understand that there's also the mailing list archives, somewhere on winehq.org, and the news group comp.emulators.ms-windows.wine, you'll inevitably find heaps of information in those two places if you spend long enough refining your search keys. Still, that's no substitute for good documentation.
Please let me know how you get on.
-- Kevin.
Kevin Cousins kevin@proximity.com.au writes:
What you *want* to do is to arrange for the following:
WINE ---loads--> foo.exe ---calls--> bar.DLL
What you *have* to do is subtly different:
WINE ---loads--> foo.exe ---runs--> stub ---loads--> bar.DLL
Actually this shouldn't be needed anymore. You can link directly to a DLL now, all you need is to provide a .def file for it and winebuild will do the rest.
On Sun, 13 Apr 2003, Eloy A. Paris wrote:
Hi!
Sorry if this has been covered before, but I could not find any answers in the archives or by Googling...
Here's the situation: I have a Windows DLL and a small Windows program that calls functions from this DLL. The Windows program does not have a GUI (it's command-line based.) I have the C source code for this program, but don't have the source code for the DLL. I built the program with Visual C and was able to run it under WINE just fine with wcmd.
Now, I want to run this program natively under Linux - I mean, I don't want to run wcmd because that requires an X server.
The first question is: is this possible? (have a Unix program that calls functions from a native Windows DLL). I started experimenting with winelib, but am not sure if this is the correct way...
AFAIK, it is the only way.
If this is possible, how should I do it? I ran winemaker, configure, make, but am getting errors from winbebuild.
See "man winemaker". You might have to fiddle with its options, or even hand edit a Makefile.in and rerun autoconf.
Summarizing: I have the C source code. This C program calls function foo() that is in a Windows DLL. I want to run this program under Linux without the need for an X server. The program calls gets(), printf(), etc. I want these functions to be from my Linux's libc, not Windows'.
A winelib program is sort of a Linux program. If it doesn't import msvcrt nor crtdll, C function calls will resolve to the Linux libc, and it has access to the Linux fd's and environment (if Linux is Wine's host *NIX OS).
You get this letter from pine, by way of a little winelib program that reads Linux stdin and stuffs it into an ole storage object outbox.
Any help will be greatly appreciated.
Thanks in advance!
Eloy.-
P.S. I read the winelib user guide, but couldn't find the answer there. If it is there, it's not clear to me :(
Doco is not our strong point, but we try.
Lawson -- ---oops---
________________________________________________________________ Sign Up for Juno Platinum Internet Access Today Only $9.95 per month! Visit www.juno.com
Thanks to all that responded.
Just a quick summary of where I stand: after reading the message from Dan Kegel dank@kegel.com I decided to try to make my current Windows console program work under Wine without X. I unset my DISPLAY variable a run Wine like this:
wine -- myprogram.exe param1
I was pleasantly surprised to see that this worked like a charm! The program read its input from stdin and sent its output to stdout; no messing with X!
wine -v reports 20030115.
It'd be nice to compile myprogram.c as a Linux program, and have that program use the Windows DLL, but I don't really know how to do that, and the docs. are not clear enough for me (or seem out of date.)
So, for now, I am all set and happy that myprogram.exe works just fine without X :)
Thank again.
Cheers,
Eloy.-
On Sun, Apr 13, 2003 at 07:09:48PM -0400, Eloy A. Paris wrote:
Hi!
Sorry if this has been covered before, but I could not find any answers in the archives or by Googling...
Here's the situation: I have a Windows DLL and a small Windows program that calls functions from this DLL. The Windows program does not have a GUI (it's command-line based.) I have the C source code for this program, but don't have the source code for the DLL. I built the program with Visual C and was able to run it under WINE just fine with wcmd.
Now, I want to run this program natively under Linux - I mean, I don't want to run wcmd because that requires an X server.
The first question is: is this possible? (have a Unix program that calls functions from a native Windows DLL). I started experimenting with winelib, but am not sure if this is the correct way...
If this is possible, how should I do it? I ran winemaker, configure, make, but am getting errors from winbebuild.
Summarizing: I have the C source code. This C program calls function foo() that is in a Windows DLL. I want to run this program under Linux without the need for an X server. The program calls gets(), printf(), etc. I want these functions to be from my Linux's libc, not Windows'.
Any help will be greatly appreciated.
Thanks in advance!
Eloy.-
P.S. I read the winelib user guide, but couldn't find the answer there. If it is there, it's not clear to me :(