Running windows DLL functions from GCC application

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
robiwan
Newbie
Newbie
Posts: 4
Joined: Tue Dec 13, 2011 10:05 am

Running windows DLL functions from GCC application

Post by robiwan »

I have a windows native DLL from which I need to execute functions, from within a GCC compiled linux executable. Could someone direct me to relevant docs for this ? :)

Thanks!!
robiwan
Newbie
Newbie
Posts: 4
Joined: Tue Dec 13, 2011 10:05 am

Post by robiwan »

Ok, browse the topic via google, would I be correct to say that if I convert my cmdline application to a winelib appl (compiled via winegcc), I can use both linux and windows apis, and thus have access to LoadLibrary/GetProcAddress ?
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Running windows DLL functions from GCC application

Post by vitamin »

robiwan wrote:I have a windows native DLL from which I need to execute functions, from within a GCC compiled linux executable.
Simple answer - you can't.

Longer answer - just build your program as win32 program and run inside Wine. Use mingw, to comile win32-pe binaries on Linux

Long answer - use winelib. But do understand that created binary will only run under Wine and only with specific Wine version. And it will not be a standalone app. That means you can not distribute your program by itself in binary format, but it will have to be packaged together with your Wine version.

Yes, winelib app can see both win32 API and POSIX API. But they do not coexist together well in all areas and you have to do extra work when mixing the two. Example: synchronization, files, GUI, network.
robiwan
Newbie
Newbie
Posts: 4
Joined: Tue Dec 13, 2011 10:05 am

Re: Running windows DLL functions from GCC application

Post by robiwan »

vitamin wrote:Yes, winelib app can see both win32 API and POSIX API. But they do not coexist together well in all areas and you have to do extra work when mixing the two. Example: synchronization, files, GUI, network.
As the DLL I'll be calling merely does calculations, I hope to avoid those problems. But to dig in a bit, is it necessary to use winegcc to build a winelib application or would -lwine with gcc suffice ?
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Running windows DLL functions from GCC application

Post by vitamin »

robiwan wrote:As the DLL I'll be calling merely does calculations, I hope to avoid those problems.
Does it allocate memory? Does it import any functions (use winedbump to check).If the answer is yes to either of the above questions then it's not that simple.
robiwan wrote:But to dig in a bit, is it necessary to use winegcc to build a winelib application or would -lwine with gcc suffice ?
You have to use winegcc.
robiwan
Newbie
Newbie
Posts: 4
Joined: Tue Dec 13, 2011 10:05 am

Re: Running windows DLL functions from GCC application

Post by robiwan »

vitamin wrote:Does it allocate memory?
Doesn't winelib wrap all Windows specific allocations (GlobalAlloc/Free etc)?
If memory allocations/frees are just within the DLL function (i.e. no pointers are returned from function calls), shouldn't that be just fine ?
vitamin wrote:Does it import any functions (use winedbump to check).
I think not, at least nothing outside core Windows DLLs (hopefully only kernel32, which I'll check), which I hope winelib should be able to handle ?
vitamin wrote:You have to use winegcc.
Ok, fair enough.
Locked