Using custom node packages in Electron


I am trying to use a custom node package that I wrote in an Electron application and I am having trouble getting the resulting DLL/Node package to initialize. When I launch my Electron application, I get the following error:

Uncaught Error: A dynamic link library (DLL) initialization routine failed.

The DLL being linked is a simple library written in C++ that has one function that takes a double as an input and simply adds one to it, returning the result. To build the C++ library, I use SWIG ( and node-gyp with the following commands:

swig -c++ -javascript -node ./src/mace_api.i
node-gyp clean configure build

mace_api is the package I am trying to build. mace_api.i, the binding.gyp file, and the source files for my library are defined as follows:


%module MaceAPI

 #include "./mace_api.cpp"

%include <windows.i>
%include "./mace_api.h"


  "targets": [
      "target_name": "mace-api",
      "sources": [ "./src/mace_api_wrap.cxx" ]


#ifndef MACE_API_H
#define MACE_API_H

#include <iostream>
#include <functional>
using namespace std;

class MaceAPI


    double addOne(double input);


#endif // MACE_API_H


#include "mace_api.h"


double MaceAPI::addOne(double input)
    double ret = input + 1.0;
    return ret;

SWIG takes the C++ source files and basically writes a wrapper that can be used, in this case, by node-gyp to build a Node package. Has anyone tried to use a custom Node module built in this manner in an Electron application? Am I missing something with how SWIG generates a wrapper for my C++ library, or how Electron handles custom Node packages? Any help would be appreciated.

For completeness, below is how I am trying to include and use my package in my Electron application:

var libMaceTest= require('mace-api/build/Release/mace-api');
var test = new libMaceTest.MaceAPI();