milasudril
2011-Jan-16 14:48 UTC
[Wine] Winelib Calling POSIX function from Windows application
Suppose that I have Windows application using Code: LoadLibrary followed by Code: GetProcAddress It should be possible to load a library implemented in terms of POSIX function but I do not understand how. Should I load the dll.so file generated by winegcc or do i need a plain .dll file?[/code]
vitamin
2011-Jan-16 16:35 UTC
[Wine] Re: Winelib Calling POSIX function from Windows application
milasudril wrote:> Should I load the dll.so file generated by winegcc or do i need a plain .dll file?Both should work on Wine.
milasudril
2011-Jan-16 18:13 UTC
[Wine] Re: Winelib Calling POSIX function from Windows application
So I write a .spec file and compile it into a .o using Code: winebuild -E foo.dll.spec -o foo.dll.s --dll foo.o foo.o was created from foo.c using winegcc. This generates a piece of assembly for me. Then I run Code: as -o foo.dll.o foo.dll.s to create object code. I also have a foo.dll.so which is created from foo.o in the makefile created by winemaker. It works to LoadLibrary("foo.dll.so") but I can not GetProcAddress (I guess the function has not been exported since the makefile does not even use the .spec file. How do I put it all together?
Thunderbird
2011-Jan-16 18:22 UTC
[Wine] Re: Winelib Calling POSIX function from Windows application
Something like this works: winegcc -m32 -shared -o test.dll test.c test.spec The file test.spec has to export your functions e.g: @ stdcall myFunction(ptr long) The test.c file in this case has lets say the prototype: void WINAPI myFunction(void *some_pointer, int value) (Note the calling convention is critical; for int/long/float you use long in the spec file, for any pointer, obviously ptr)
milasudril
2011-Jan-16 19:29 UTC
[Wine] Re: Winelib Calling POSIX function from Windows application
Thunderbird wrote:> Something like this works: > winegcc -m32 -shared -o test.dll test.c test.spec > > The file test.spec has to export your functions e.g: > @ stdcall myFunction(ptr long) > > The test.c file in this case has lets say the prototype: > void WINAPI myFunction(void *some_pointer, int value) > (Note the calling convention is critical; for int/long/float you use long in the spec file, for any pointer, obviously ptr)Thanks! That explanation was better than the much longer Winelib tutorial. Calling conventions: How do I use long long and double?
Thunderbird
2011-Jan-16 20:18 UTC
[Wine] Re: Winelib Calling POSIX function from Windows application
For double you use long as well. For long long you need int64. Watch out with types long long in function prototypes on 64-bit since win32 and unix have different sizes for them on 64-bit (LONG=32bit on Windows, long=64-bit on Linux and long long on Linux would be 128-bit whereas on windows it is 64-bit).