Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This package does not run on Windows #52

Open
masasso opened this issue May 15, 2023 · 9 comments
Open

This package does not run on Windows #52

masasso opened this issue May 15, 2023 · 9 comments

Comments

@masasso
Copy link

masasso commented May 15, 2023

Hello,

I am trying to use this package in my application but it does not work in windows computers. After sime research I believe that in file src/hdf5_util.cc every .c_str() must be replaced for .data().

Could you try that for me?

I created this fork (https://github.com/masasso/h5wasm) to solve the problem but as I dont know much about web assembly I am not able to compile the project.

Thanks in advance.

@bmaranville
Copy link
Member

I'm afraid I haven't set it up to be built on Windows. The Makefile is not compatible with Windows, and there may be other issues such as the one you found. If you would like to submit a pull request with a working build setup for Windows, I'd be happy to add it to the package.

It can certainly be built in a linux container within WSL running on Windows, if you are unable to get a MacOS or linux machine on which to build, and once it is built, it of course runs in the browser on any platform.

Sorry I can't be more help right now.

@masasso
Copy link
Author

masasso commented May 15, 2023

How actually you test your updates?
I am trying to install the package I created with npm install https://github.com/masasso/h5wasm but node does not recognize it.
If you can give me some instructions on how to add more updates and check it is working I would be more than happy to help.

The problem is that I am building a vscode extension that must work for any user in the main operation systems (Windows, Linux and Mac)

@bmaranville
Copy link
Member

You don't need to build h5wasm on every operating system - I build it using linux or MacOS then package the wasm build into an npm package and publish it, then users of any operating system can install with npm and they will get the binary wasm code that will run on their system.

@masasso
Copy link
Author

masasso commented May 15, 2023

What I did in my https://github.com/masasso/h5wasm was.

  1. Replaced every .c_str() for .data() in h5wasm/src/hdf5_util.cc
  2. Installed Emscripten and followed all the instructions
  3. Called make
  4. Called npm run build
  5. Commited with the new ./src/hdf5_hl.d.ts file created.

What I did in my personal package that is using it:

  1. npm instal https://github.com/masasso/h5wasm
  2. Next I imported it in my project import h5wasm from "h5wasm";
  3. But I get an error: Activating extension failed: Cannot find module 'h5wasm'.

I am doing everything on Linux first to check if it works, but now even in Linux it does not work. Am I missing something?

@bmaranville
Copy link
Member

you haven't committed your 'dist' folder to your github repo. If you want to install directly from github the compiled files have to be there in the repo. I am using the npmjs repo to host the compiled files because it is awkward to commit large compiled files to github, but for your testing it should be fine.

@masasso
Copy link
Author

masasso commented May 15, 2023

Have you already faced this problem. I never touched this part of the code in file node_esm_shim.js
Activating extension i' failed: Module parse failed: Identifier 'createRequire' has already been declared (6:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| globalThis.require = createRequire(import.meta.url);
|

import { createRequire } from 'module';
| const require = createRequire(import.meta.url);
| .

@bmaranville
Copy link
Member

Can you tell me which version of emscripten you are using?

@masasso
Copy link
Author

masasso commented May 15, 2023

The latest version at https://github.com/emscripten-core/emsdk

So it should be 3.1.38
Toggle commit message

@bmaranville
Copy link
Member

You can remove the line
--extern-pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src/node_esm_shim.js \
from CMakeLists.txt if you are using a very recent emscripten like you are.

Also it looks like the more recent versions of emscripten are stripping the _malloc and _free functions with -O3, so I added them to the explicit export list (pull the most recent version of h5wasm).

I was able to run the test with npm test after building with your version of emscripten (with the change to CMakeLists.txt described above, that is not in the current h5wasm repo so you'll have to make it yourself)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants