Hi,
I wrote to the list a few weeks ago. I needed to support a USB device without changing the Windows dll that I have to use. I was trying to hack into wine to implement support for the USB device using CreateFile() and DeviceIoControl(). That was not a clean solution.
The author of the Windows dll has agreed to support a mid level dll that would implement functions like USBDeviceOpen(), USBDeviceClose(), USBDeviceRead(), and USBDeviceWrite(). On Windows those would use CreateFile() and DeviceIoControl(), while on Linux they would use libusb calls.
I followed the example from winelib user guide, chapter 5 "Using Linux libraries as DLLs" As an example I will talk just about USBDeviceOpen(). Here it is how it is declared together with a proxy function:
HANDLE WINAPI USBDeviceOpen(const DWORD in_dwIndex); HANDLE WINAPI USBDeviceOpenProxy(const DWORD in_dwIndex);
This function opens a specific device from a specific manufacturer. If more than one device connected
In the spec file I put:
101 stdcall USBDeviceOpen (long) USBDeviceOpenProxy
I used winemaker, configure, make, and make install. Now I have "USBUtils.dll.so in /
Sorry, I hit send by mistake. Here is the entire message.
Hi,
I wrote to the list a few weeks ago. I needed to support a USB device without changing the Windows dll that I have to use. I was trying to hack into wine to implement support for the USB device using CreateFile() and DeviceIoControl(). That was not a clean solution.
The author of the Windows dll has agreed to support a mid level dll that would implement functions like USBDeviceOpen(), USBDeviceClose(), USBDeviceRead(), and USBDeviceWrite(). On Windows those would use CreateFile() and DeviceIoControl(), while on Linux they would use libusb calls.
I followed the example from the winelib user guide, chapter 5 "Using Linux libraries as DLLs" As an example I will talk just about USBDeviceOpen(). Here it is how it is declared together with a proxy function:
HANDLE WINAPI USBDeviceOpen(const DWORD in_dwIndex); HANDLE WINAPI USBDeviceOpenProxy(const DWORD in_dwIndex);
This function opens a specific device from a specific manufacturer. If more than one device is connected, the index will specify which device to open.
In the spec file I put:
101 stdcall USBDeviceOpen (long) USBDeviceOpenProxy
I used winemaker, configure, make, and make install. Now I have "USBUtils.dll.so in /usr/lib/wine.
I wrote a small test program. It has a WinMain function and it calls USBDeviceOpen. I used winemaker again and I am running the test application this way:
# wine -- test.exe.so
If I call USBDeviceOpenProxy (or any other proxy function), the test application links and runs correctly. I tested all functions and they work as expected.
But, if I call USBDeviceOpen, the application does not link (undefined USBDeviceOpen). If I use the C compiler (instead of C++) the application links, but at runtime it does not find USBDeviceOpen.
I don't understand how Windows dlls and Linux libraries link and how functions are called. What am I missing?
I would appreciate any help.
Dan Timis Muse Research, Inc.
On December 31, 2003 07:33 pm, Dan Timis wrote:
I don't understand how Windows dlls and Linux libraries link and how functions are called. What am I missing?
Please use winegcc to build the test app. It does a number of housekeeping tasks behing the scene that might help.
Thanks Dimi, and "La multi ani" (Happy new year).
I'm new to this so please bear with me.
First I edited the Makefile and replaced gcc with winegcc. When I run "make" I get this error when it tries to link:
could not open .def file for kernel32 Error: /usr/bin/winebuild failed. Error: /usr/bin/winewrap failed.
Then, I ran ./configure --help and it says that you can use the "CC" var to specify the compiler. I started from scratch, set "export CC=winegcc", then ran configure again. The output looks like this:
checking whether make sets {$MAKE}... yes checking for gcc... winegcc checking for C compiler default output... configure: error: C compiler cannot create executables
Thanks,
Dan
On Wednesday, December 31, 2003, at 04:57 PM, Dimitrie O. Paun wrote:
On December 31, 2003 07:33 pm, Dan Timis wrote:
I don't understand how Windows dlls and Linux libraries link and how functions are called. What am I missing?
Please use winegcc to build the test app. It does a number of housekeeping tasks behing the scene that might help.
-- Dimi.
On January 2, 2004 05:13 pm, Dan Timis wrote:
Thanks Dimi, and "La multi ani" (Happy new year).
Hey, La Multi Ani! to you too :)))
I'm new to this so please bear with me.
First I edited the Makefile and replaced gcc with winegcc. When I run "make" I get this error when it tries to link:
could not open .def file for kernel32 Error: /usr/bin/winebuild failed. Error: /usr/bin/winewrap failed.
Can you please send me the command that generates this? Just to make sure that we're on the same page, use winegcc (for now) just for building the test application, not the DLL.
Then, I ran ./configure --help and it says that you can use the "CC" var to specify the compiler. I started from scratch, set "export CC=winegcc", then ran configure again. The output looks like this:
checking whether make sets {$MAKE}... yes checking for gcc... winegcc checking for C compiler default output... configure: error: C compiler cannot create executables
This is very odd. winegcc should be configure friendly (it does work for wxWindows BTW). Hey, what version of Wine are you using? I do hope it's the latest CVS...
On Saturday, January 3, 2004, at 01:07 AM, Dimitrie O. Paun wrote:
I'm new to this so please bear with me.
First I edited the Makefile and replaced gcc with winegcc. When I run "make" I get this error when it tries to link:
could not open .def file for kernel32 Error: /usr/bin/winebuild failed. Error: /usr/bin/winewrap failed.
Can you please send me the command that generates this? Just to make sure that we're on the same page, use winegcc (for now) just for building the test application, not the DLL.
Then, I ran ./configure --help and it says that you can use the "CC" var to specify the compiler. I started from scratch, set "export CC=winegcc", then ran configure again. The output looks like this:
checking whether make sets {$MAKE}... yes checking for gcc... winegcc checking for C compiler default output... configure: error: C compiler cannot create executables
This is very odd. winegcc should be configure friendly (it does work for wxWindows BTW). Hey, what version of Wine are you using? I do hope it's the latest CVS...
I am using an older version 20030618. It's hard to change, other people depend on this particular version and I would have to upgrade several machines. I could try on one machine, but...
A colleague who dealt with similar problems in the past helped me. He added this to Makefile.in
# generate a .def "import library" file from the spec file $(usbutils_dll_DEF): $(usbutils_dll_SPEC_SRCS) Makefile.in $(WINEBUILD) --def $(usbutils_dll_SPEC_SRCS) > $(usbutils_dll_DEF)
Both the .dll.so and the .def go in /usr/lib/wine/wine. Earlier I noticed that there was no .def file. That was our clue.
For the test we added the library to the list of wine dlls in Makefile.in.
It's working. I'm still a little confused, but I understand much more than a week ago. Thanks.
Dan Timis Muse Research, Inc.