15

Scenario

I have a plugin (dll) written for a Windows application (in C++).

That application works fine on Linux under Wine, however, in the plugin I would like to use a feature which is not yet available in Wine.

Assuming I can detect at runtime that the application is running in Wine, can I dynamically load native Linux library (or access native Linux API in any other way) in order to emulate said feature?

I am curious whether this can be done without any serious hacking.

6
  • 1
    How about writing a native Linux application? If done "right", you'll end up with a cross-platform solution that works on Linux and Windows. But this is an interesting question nonetheless.
    – rubenvb
    Commented Sep 19, 2016 at 13:36
  • Thanks, but am writing a plugin to foobar2000 which is a closed-source Windows only music player.
    – user6846474
    Commented Sep 19, 2016 at 13:38
  • 1
    I would write a cross-platform executable program, and two small OS-specific loadable plugins that talk to it via a pipe or some other mechanism. Commented Sep 19, 2016 at 13:45
  • What API are we talking about anyway?
    – rubenvb
    Commented Sep 19, 2016 at 14:00
  • Wine provides Windows features on Linux. Are you saying you want to use a Windows feature that Wine does not yet support, so you propose to emulate it? If you mean to do that, then maybe you should add the feature to Wine itself, instead. Commented Sep 19, 2016 at 14:09

1 Answer 1

7

Seems like someone has faced similar problem, or at least has predicted such situation. Wrapper-library should help you:

For one reason or another you may find yourself with a Linux library that you want to use as if it were a Windows DLL. There are various reasons for this including the following:

...

  1. You have a binary only Windows application that can be extended through plugins, such as a text editor or IDE.

In few words - you should create thin Wine builtin-dll, that acts like a bridge between ABI of your PE binary and ABI of native Linux Library. Then you should link your code against this wrapper. For Windows distribution you can provide "wrapper" with empty stubs. Such approach allows you to use one binary for your plugin, that will use wine-specific functional wrapper DLL on Linux and stub DLL on Windows.

1
  • Thank you! This isn't the direct native call approach I had in mind but it does make sense. Use Wine's own tools to build a Wine DLL. I'll give this a try.
    – user6846474
    Commented Sep 19, 2016 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.