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

"ERROR:root:cwrap]': No such file or directory" #174

Open
DragonOsman opened this issue Sep 27, 2018 · 9 comments
Open

"ERROR:root:cwrap]': No such file or directory" #174

DragonOsman opened this issue Sep 27, 2018 · 9 comments

Comments

@DragonOsman
Copy link

I tried to follow the int_sqrt example here: https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html but I got an error saying

ERROR:root:cwrap]': No such file or directory ("cwrap]'" was expected to be an input file, based on the commandline arguments provided)

Could someone please help me out here?

@kripken
Copy link
Member

kripken commented Sep 29, 2018

Probably an escaping issue or a typo in the command you wrote. What was the command, and in what shell?

@kripken
Copy link
Member

kripken commented Sep 29, 2018

(By the error message, ("cwrap]'", I suspect you need to move the quotes around, to ("cwrap"]')

@DragonOsman
Copy link
Author

DragonOsman commented Sep 29, 2018

I did it in the correctly set-up terminal (with the environment set) and I ran the command with double-quotes around "cwrap".

This was the command I ran, in both WSL and in regular Windows mode (with the correct modifications made to the command):

./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'

I can get ccall to work, but not cwrap. I tried this example, which uses ccall but not cwrap, and got it to work: https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm#Calling_a_custom_function_defined_in_C .

Edit to add: The source emsdk_env.bat (Windows) and source ./emsdk_env.sh (Linux/WSL (?)) command doesn't work either; I get an error indicating that it doesn't know the command.

@DragonOsman
Copy link
Author

So no one is able to help me out?

Again, I followed the aforementioned tutorial and called cwrap exactly as it says and I still got that error. I need help on this.

Also, there's that other issue I opened about porting my web server application to WebAssembly as a module to use on the backend through Node. The code for the app is here. I also wrote an asynchronous version of the code, but on that one I'm having trouble with making the client code asynchronous because of the code in cache_storage::query() that I need to convert to be asynchronous.

And because this uses Beast which is based of ASIO (which doesn't support WebAssembly), I need to know how to port ASIO to WebAssembly as well.

@kripken
Copy link
Member

kripken commented Nov 12, 2018

I don't know much about WSL, but this seems like an escaping issue. Might be worth trying all the other possibilities, like -s 'X=["y"]' for example (note ' are around the key, the equals, and the value).

@DragonOsman
Copy link
Author

DragonOsman commented Nov 16, 2018

Just now, I again tried to run this same command:

emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'

exactly as documented in the tutorial, but I got this same error again:

ERROR:root:cwrap]': No such file or directory ("cwrap]'" was expected to be an input file, based on the commandline arguments provided)

I'm sure I didn't make any mistakes. I just copy-pasted the command as is from the tutorial here. There shouldn't be any mistakes. I ran this command:

emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'

Also, just now, I tried to build my currency_converter.cpp app with this command:

em++ -std=c++17 -Wall -pedantic -D variant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD -s DISABLE_EXCEPTION_CATCHING=0 -I C:/Jinja2Cpp/install_x64/include -I C:/json/single_include -I C:/boost_1_68_0/ -c currency_converter.cpp -L C:/Jinja2Cpp/install_x64/lib/static/jinja2cpp.lib -L C:/boost_1_68_0/lib64-msvc-14.1/libboost_system-vc141-mt-x64-1_68.lib -lpthread -o currency_converter.js

and it didn't generate a .wasm file. I tried entering the command node currency_converter.js as well, but I got this error:

E:\programming\visual_studio_2017\Projects\currency_converter\currency_converter\currency_converter.js:1
(function (exports, require, module, __filename, __dirname) { BC��5�
                                                                ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

And I tried to open the .js file as well. There's nothing to show, though. No file coming in Visual Studio. Is there something I missed in the command I entered? The app source code is on GitHub here.

@DragonOsman
Copy link
Author

DragonOsman commented Nov 16, 2018

On second thought, It could be because I have to give special treatment to std::shared_ptr when trying to compile to WebAssembly. I'll have to read again about how to do that.

Also, if I want to pass API keys as environment variables to use in my WebAssembly application, and I want to use it as a Node.js module, should I use ENV in my Node.js code like this?

Module.preRun.push(function() {ENV.my_key = "value"})

Edit: If I want to use a std::shared_ptr and I have it like this:

std::make_shared<listener>(ioc, tcp::endpoint{ address, port }, doc_root)->run();

how do I do it using EMSCRIPTEN_BINDINGS? I also need to know about how to do it with std::enable_shared_from_this<>.

Edit: @kripken I need some help here if you're free. I can't generate .wasm code at all for my app. Code is here and compilation command I used is:

em++ -std=c++17 -Wall -pedantic -D variant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD -I C:/Jinja2Cpp/install_x64/include -I C:/json/single_include -I C:/boost_1_68_0/ -I C:/Users/Osman/emsdk/emscripten/1.38.18/system/include/ -c currency_converter.cpp -s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_PTHREADS=1 -L C:/Jinja2Cpp/install_x64/lib/static/jinja2cpp.lib -L C:/boost_1_68_0/lib64-msvc-14.1/libboost_system-vc141-mt-x64-1_68.lib -lpthread -o currency_converter.js

And as I said before, just a bit ago I ran this command (copy-pasted it as is from the Emscripten tutorial on ccall and cwrap, except I used emcc instead of ./emcc):

emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'

And it still gave me that same error as before.

In my compilation command for my app, I'm also going to try it by putting the -s flags after -o currency_converter.js flag and see if it helps. Also, please let me know if I need to use EMSCRIPTEN_BINDINGS with std::shared_ptr when I'm going to use the WASM module as a Node.js module on the backend. I have my own HTML, CSS and JavaScript files that go with my app and my C++ code is a webserver that serves them up and also does the currency conversion calculation (getting the conversion rates from a currency API by making a GET request). So I'm trying to compile a webserver to WebAssembly, which is why I want to use it with Node.

Edit: Okay, putting the -s stuff after the -o flag didn't help either.

@hainawa
Copy link

hainawa commented Sep 3, 2019

I've met the same problem.After trying several times,I found it could be resolved by change ' to ":
emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS="['_int_sqrt']" -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']"

@raspiduino
Copy link

For someone who export functions in cmake, -sEXPORTED_FUNCTIONS=['_int_sqrt'] -sEXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap'] worked for me!

See this StackOverflow post.

vargaz pushed a commit to vargaz/emsdk that referenced this issue Nov 22, 2023
* Workload changes and arcade update (emscripten-core#171) (emscripten-core#172)

* Update arcade to 7.0.0-beta.22416.1

* Workload changes

Co-authored-by: Larry Ewing <[email protected]>

Co-authored-by: Juan Hoyos <[email protected]>

* [release/7.0-rc1] Make two manifests one for net7 and one for net6 in 7.0.100 sdk band (emscripten-core#163)

* Here goes nothing

* Update WorkloadManifest.json.in

* Update WorkloadManifest.json.in

* Try to fix up the multi-targeted build. This will likely need an arcade change to enable manifests withtout packs and an additional change once arcade is updated.

* Update eng/emsdk.proj

Co-authored-by: Alexander Köplinger <[email protected]>

* Rename .pkgproj files

* Update PackageVersionNet6 to 6.0.9

* Fix the location of the .net7 pkgproj

Co-authored-by: Marc Paine <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>

* [release/7.0-rc1] Shorten the name more (emscripten-core#174)

* Shorten the name more

* [release/7.0-rc1] Check nuget sizes and fix them (emscripten-core#175)

* yml: Fail if nuget size exceeds 250MiB, on linux, and macos

* Fix the case for no errors

* Remove unused binaries

Co-authored-by: Ankit Jain <[email protected]>

* Add PowerShell-based NuGet size check script and use it on Windows (emscripten-core#176)

* Add PowerShell-based NuGet size check script and use it on Windows

* Update azure-pipelines.yml

Co-authored-by: Juan Hoyos <[email protected]>
Co-authored-by: Marc Paine <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
vargaz pushed a commit to vargaz/emsdk that referenced this issue Nov 22, 2023
* Workload changes and arcade update (emscripten-core#171) (emscripten-core#172)

* Update arcade to 7.0.0-beta.22416.1

* Workload changes

Co-authored-by: Larry Ewing <[email protected]>

Co-authored-by: Juan Hoyos <[email protected]>

* [release/7.0-rc1] Make two manifests one for net7 and one for net6 in 7.0.100 sdk band (emscripten-core#163)

* Here goes nothing

* Update WorkloadManifest.json.in

* Update WorkloadManifest.json.in

* Try to fix up the multi-targeted build. This will likely need an arcade change to enable manifests withtout packs and an additional change once arcade is updated.

* Update eng/emsdk.proj

Co-authored-by: Alexander Köplinger <[email protected]>

* Rename .pkgproj files

* Update PackageVersionNet6 to 6.0.9

* Fix the location of the .net7 pkgproj

Co-authored-by: Marc Paine <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>

* [release/7.0-rc1] Shorten the name more (emscripten-core#174)

* Shorten the name more

* [release/7.0-rc1] Check nuget sizes and fix them (emscripten-core#175)

* yml: Fail if nuget size exceeds 250MiB, on linux, and macos

* Fix the case for no errors

* Remove unused binaries

Co-authored-by: Ankit Jain <[email protected]>

* Add PowerShell-based NuGet size check script and use it on Windows (emscripten-core#176)

* Add PowerShell-based NuGet size check script and use it on Windows

* Update azure-pipelines.yml

* Roll back 6.0.x to 6.0.8 so that packages exist (emscripten-core#177)

* Revert "Roll back 6.0.x to 6.0.8 so that packages exist (emscripten-core#177)" (emscripten-core#178)

This reverts commit b7a5ae2.

* make a 6.0.4 build (emscripten-core#180)

* Revert "make a 6.0.4 build (emscripten-core#180)" (emscripten-core#181)

This reverts commit eb3232e.

* [release/7.0] Update arcade to 7.0.0-beta.22418.4 (emscripten-core#182)

* WorkloadManifest.targets: fix condition (emscripten-core#183)

Co-authored-by: Juan Hoyos <[email protected]>
Co-authored-by: Marc Paine <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
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

4 participants