mljs / libsvm

LIBSVM for the browser and nodejs :fire:
https://mljs.github.io/libsvm/
BSD 3-Clause "New" or "Revised" License
82 stars 14 forks source link

Unable to Build #23

Open Neuroforge opened 10 months ago

Neuroforge commented 10 months ago

Hello,

I am trying to build this library as i'd like to see how it works with the latest version of LibSVM.

Is this possible? First, i'm trying to just build it as is, using the current version released on npm.

If i checkout the repo and build the code and install it my project i get the following error....

TypeError: libsvm.load is not a function.

In the wasm.js file in the root folder i've added a console log to see if i can figure out why it is not loading.

'use strict';

const loadSVM = require('./src/loadSVM');
const libsvm = require('./out/wasm/libsvm');

console.log(libsvm)
module.exports = libsvm.load().then(() => loadSVM(libsvm));

Output from my build

Promise { <pending> }

Output from npm package

It looks like the promise is in fact resolved.

Screenshot 2023-10-23 at 3 14 43 pm

Any idea what could be happening here?

Follow up...

I've tried to alter wasm.js to resolve the promise....

'use strict';

const loadSVM = require('./src/loadSVM');
const libsvm = require('./out/wasm/libsvm');

console.log(libsvm);
module.exports = libsvm.then((p) => {
  console.log(p);
  return p.load().then(() => loadSVM(libsvm));
});

This turns up the following error


TypeError: libsvm.cwrap is not a function
    at module.exports (/Users/daniel/Desktop/libsvm/src/loadSVM.js:7:30)
    at /Users/daniel/Desktop/libsvm/wasm.js:10:30

All of the other jazz is logged out now correctly....

Screenshot 2023-10-23 at 3 32 49 pm

I've look on Stackoverflow and there is a thread on...

https://stackoverflow.com/questions/56040210/uncaught-typeerror-module-cwrap-is-not-a-function

But it seems this is already factored into the build configuration in the make file -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap", "Pointer_stringify"]'

This param has been depricated in favour of ...

-sEXPORTED_RUNTIME_METHODS=cwrap,Pointer_stringify

but i still get a warning about Pointer_stringify.

(It seems that Pointer_stringify is used in the serialize method of libsvm, but that isn't important and i could just remove it)