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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 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 Sep 19 '16 at 13:36
  • Thanks, but am writing a plugin to foobar2000 which is a closed-source Windows only music player. –  Sep 19 '16 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. – n. m. could be an AI Sep 19 '16 at 13:45
  • What API are we talking about anyway? – rubenvb Sep 19 '16 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. – John Bollinger Sep 19 '16 at 14:09
  • I want to create symbolic links which for some reason does not work. –  Sep 19 '16 at 14:11

1 Answers1

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.

Sergio
  • 8,099
  • 2
  • 26
  • 52
  • 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. –  Sep 19 '16 at 15:47