justmoon / node-bignum

Big integers for Node.js using OpenSSL
419 stars 116 forks source link

symbol lookup error: BN_new on electron project #117

Open pc-magas opened 5 years ago

pc-magas commented 5 years ago

I managed to install the library to my project like that:

npm install bignum
./node_modules/.bin/electron-rebuild

But when I try to launch my electron application to a Ubuntu 16.04Lts machine even though I managed to make run without issues during the execution I get the following error:

symbol lookup error: /home/pcmagas/Kwdikas/master_thesis/custom_xmpp/node_modules/bignum/build/Release/bignum.node: undefined symbol: BN_new

I also tried to reinstall all the libraries as well via the following command set:

rm -rf ./node-modules
npm install
./node_modules/.bin/electron-rebuild

But I still get the error do you know why?

The error can be reproduced into he following code:

const { app, BrowserWindow, ipcMain } = require('electron');
const bignum = require('bignum');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

const bignumValue = bignum("FFA122310DC", 16);

const createWindow = () => {
  // Create the browser window.
  mainWindow = new BrowserWindow({
      globals:{
          num: bignumValue.toString()
      }
  });
  mainWindow.setMenu(null);
  mainWindow.maximize();

  // and load the index.html of the app.
  mainWindow.loadURL(`file://${__dirname}/index.html`);

  mainWindow.on('closed', () => {
    mainWindow = null;
  });
};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

app.on('before-quit', () => {
  if (xmpp) {
    xmpp.disconnect();
  }
});

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // On OS X it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (mainWindow === null) {
    createWindow();
  }
});

process.on('unhandledRejection', (reason, p) => {
  console.error('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});

process.on('SIGINT', () => {
  if (xmpp) {
    xmpp.disconnect();
  }
  process.exit(0);
});

But a native nodejs code runs without errors for example this piece of code:

const bignum = require('bignum');
const big = bignum('AAFCD11234334BBAAFD',16);
console.log(big.toString());

Outputs the following sucessfully:

50466621672219557473021