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

Failed when using --emit-tsd to generate .d.ts from cpp #22181

Open
wangyuanhao11 opened this issue Jul 3, 2024 · 11 comments
Open

Failed when using --emit-tsd to generate .d.ts from cpp #22181

wangyuanhao11 opened this issue Jul 3, 2024 · 11 comments

Comments

@wangyuanhao11
Copy link

when i use emcc like this:

emcc E:\test.cpp -o test.js -sMODULARIZE -s EXPORT_ES6=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_ALL=1 -lembin
d --emit-tsd test.d.ts

The error message it reports is as follows:

emcc: error: 'tsc --outFile C:\Users\BON0027\AppData\Local\Temp\emscripten_temp_1vipmldr\jsdoc.d.ts --declaration --emitDeclarationOnly --allowJs C:\Users\BON0027\AppData\Local\Temp \emscripten_temp_1vipmldr\jsdoc.js' failed: [WinError 2] The system cannot find the file specified.

What is the cause of this and how can I fix it,?any suggestions would be greatly appreciated!

@sbc100
Copy link
Collaborator

sbc100 commented Jul 3, 2024

You need to have the typescript compiler installed on your system. I think the simplest way is to do npm install --g typescript.
@brendandahl is this the recommended command? Should we report a more meaningful error when its not in the path?

@brendandahl
Copy link
Collaborator

We should show an error if the user doesn't have tsc installed or the npm package doesn't exists. In this case, it seems like something is wrong with the typescript that is currently installed.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 3, 2024

@wangyuanhao11, what happens if you type tsc? How about where tsc?

@wangyuanhao11
Copy link
Author

I have installed ts and the where tsc is :
C:\Program Files\nodejs\tsc
C:\Program Files\nodejs\tsc.cmd

i tried :

docker run --rm -it -v ./src:/src -u $(id -u):$(id -g)
emscripten/emsdk bash -c "npm i -g typescript &&
emcc hello.cpp -o hello.js -lembind -sEXPORT_ES6=1 --emit-tsd hello.d.ts"

I have tried to follow the official documentation and I think my ts has been installed successfully,But it's the same error.
So this error doesn't make sense?

@wangyuanhao11
Copy link
Author

I have installed tsc and i tried according to
https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/porting/connecting_cpp_and_javascript/embind.rst#typescript-definitions
but it doesn't work. How can I solve this problem, any help would be greatly appreciated!@sbc100 @brendandahl

@sbc100
Copy link
Collaborator

sbc100 commented Jul 8, 2024

What happens if you run tsc --version?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 8, 2024

i tried :

docker run --rm -it -v ./src:/src -u (id−u):(id -g) emscripten/emsdk bash -c "npm i -g typescript && emcc hello.cpp -o hello.js -lembind -sEXPORT_ES6=1 --emit-tsd hello.d.ts"

I have tried to follow the official documentation and I think my ts has been installed successfully,But it's the same error. So this error doesn't make sense?

Can you share the full error output of this docker command?

I was able to run a very similar docker command without issue:

sbc.cloudtop (~/dev/wasm/emscripten) (add_missing_dep) $ docker run --rm -it -v $PWD/test:/test -w /test emscripten/emsdk bash -c "npm i -g typescript && emcc hello_world.c -o hello.js -lembind -sEXPORT_ES6=1 --emit-tsd hello.d.ts"

added 1 package in 1s
npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice To update run: npm install -g [email protected]
npm notice
cache:INFO: generating system asset: symbol_lists/8dd3d5931e463083fcb91208f818703415533cbe.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/8dd3d5931e463083fcb91208f818703415533cbe.json" for subsequent builds)
cache:INFO:  - ok

@wangyuanhao11
Copy link
Author

wangyuanhao11 commented Jul 9, 2024

my tsc version is:Version 5.5.3
and my emsdk is latest:

E:\emsdk\emsdk>emsdk install latest
Resolving SDK alias 'latest' to '3.1.62'
Resolving SDK version '3.1.62' to 'sdk-releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit'
Installing SDK 'sdk-releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit'..
Skipped installing node-18.20.3-64bit, already installed.
Skipped installing python-3.9.2-nuget-64bit, already installed.
Skipped installing java-8.152-64bit, already installed.
Skipped installing releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit, already installed.
All SDK components already installed: 'sdk-releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit'.

E:\emsdk\emsdk>emsdk activate latest
Resolving SDK alias 'latest' to '3.1.62'
Resolving SDK version '3.1.62' to 'sdk-releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit'
Setting the following tools as active:
   node-18.20.3-64bit
   python-3.9.2-nuget-64bit
   java-8.152-64bit
   releases-d52176ac8e07c47c1773bb2776ebd91e3886c3af-64bit

the error :

cache:INFO: generating system asset: symbol_lists/8dd3d5931e463083fcb91208f818703415533cbe.json... (this will be cached in "E:\emsdk\emsdk\upstream\emscripten\cache\symbol_lists\8dd3d5931e463083fcb91208f818703415533cbe.json" for subsequent builds)
cache:INFO:  - ok
emcc: error: 'tsc --outFile C:\Users\BON0027\AppData\Local\Temp\emscripten_temp_1vipmldr\jsdoc.d.ts --declaration --emitDeclarationOnly --allowJs C:\Users\BON0027\AppData\Local\Temp \emscripten_temp_1vipmldr\jsdoc.js' failed: [WinError 2] The system cannot find the file specified.

@sbc100

@sbc100
Copy link
Collaborator

sbc100 commented Jul 9, 2024

Sorry, just to be clear, you can actually run tsc --version from the command line? But when its run from inside of emcc its not working for some reason.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 9, 2024

As an random experiment, can you try install emsdk on the same drive as your node/tsc installation (C:)?

@wangyuanhao11
Copy link
Author

E:\emsdk\emsdk>where tsc
E:\emsdk\emsdk\node\18.20.3_64bit\bin\tsc
E:\emsdk\emsdk\node\18.20.3_64bit\bin\tsc.cmd

E:\emsdk\emsdk>tsc -v
Version 5.5.3

I uninstalled nodejs on the c drive. Now there is only nodejs here.
I successfully used emit-tsd on Macos system, but failed on both windows systems.
@sbc100

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

3 participants