bundling precompiled binary into electron app

后端 未结 6 1695
无人共我
无人共我 2020-11-28 22:21

Is there a good solution on how to include third party pre compiled binaries like imagemagick into an electron app? there are node.js modules but they are all wrappers or na

6条回答
  •  一向
    一向 (楼主)
    2020-11-28 23:09

    tl;dr:

    yes you can! but it requires you to write your own self-contained addon which does not make any assumptions on system libraries. Moreover in some cases you have to make sure that your addon is compiled for the desired OS.


    Lets break this question in several parts:

    - Addons (Native modules):

    Addons are dynamically linked shared objects.

    In other words you can just write your own addon with no dependency on system wide libraries (e.g. by statically linking required modules) containing all the code you need.

    You have to consider that such approach is OS-specific, meaning that you need to compile your addon for each OS that you want to support! (depending on what other libraries you may use)

    - Native modules for electron:

    The native Node modules are supported by Electron, but since Electron is using a different V8 version from official Node, you have to manually specify the location of Electron's headers when building native modules

    This means that a native module which has been built against node headers must be rebuilt to be used inside electron. You can find how in electron docs.

    - Bundle modules with electron app:

    I suppose you want to have your app as a stand-alone executable without requiring users to install electron on their machines. If so, I can suggest using electron-packager.

提交回复
热议问题