-
Notifications
You must be signed in to change notification settings - Fork 36
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
[Feature Request] Make/export Emception as a library. #7
Comments
Definitely! PR's are welcome! |
@jprendes @dr-vortex Are there any updates on making this awesome project easy to integrate? I'm asking because I'm currently developing an educational coding app for learning Algorithms and Complexity: It's almost at RC1, at the moment I'm finishing off version one, using dyodide, which so far, it's working pretty well. I really would like to add support for C/C++ once this project becomes stable. Emception is probably the most mature result I've seen out there, however for the time being, I'm having issues just compiling it on my local machine, with or without docker, (same issues as described in #11) |
@cesare-montresor JSCPP is really cool: https://github.com/felixhao28/JSCPP |
I like that project, but I like the idea of having gcc |
@cesare-montresor were you able to build it? I am also unable to create a build because of python errors: The necessary bits to build these optional modules were not found:
_bz2 _ctypes _ctypes_test
_curses _curses_panel _dbm
_gdbm _hashlib _lzma
_ssl _tkinter _uuid
readline
To find the necessary bits, look in configure.ac and config.log.
Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
configure: error: invalid or missing build python binary
make: make -j32
make: *** No targets specified and no makefile found. Stop. |
Yes, same issue, probably the docker machine needs an update. |
@cesare-montresor did you come across a similar project that works with emscripten? @jprendes any chance to get a fix? |
I can't remember where I saw it, but the python errors have to do with the newer version of pyodide being used when we try to build being different from the one @jprendes used. A hardcoded commit id in the pyodide clone/checkout should fix it. |
Here's some of my un-educated ideas for how an API might be modeled after some other existing "similarish" APIs: Here's something like Node.js' import { CPPSourceTextModule, CPPSTLLinker } from "./emception.js";
const module = new CPPSourceTextModule(String.raw`
#include <string>
#include <iostream>
int main() {
std::string message = "Hello world!";
std::cout << message << "\n";
}
`);
await module.link(CPPSTLLinker);
await module.evaluate();
// Any exports (if isn't main module)
console.log(module.namespace); Or, maybe something more like the current WASM pipeline: import { Emception } from "./emception.js";
const module = await Emception.compileStreaming(fetch("./index.cpp"));
// Somehow fetch all required functions...?
console.log(Emception.Module.imports(module));
const instance = await Emception.instantiate(module, { ... });
const exitCode = instance.exports.main(1, ["/hello"]); Then again, I think this is a bit too low-level for the kind of abstract C++ compilation that most users want. Something higher-level is probably desired. Or maybe something like what Pyodide does ( import { unpackArchive, cppimport, runCPP } from "./emception.js";
await runCPP(`
#include <string>
#include <iostream>
int main() {
std::string message = "Hello world!";
std::cout << message << "\n";
}
`);
const response = await fetch("https://example.org/your_package.tar.gz");
const buffer = await response.arrayBuffer();
await unpackArchive(buffer);
cppimport("your_package"); Then again, you could implement them all if you really wanted to! 😉 These are just brainstorming ideas that I had and wanted to share. |
@cesare-montresor I've updated my GitHub username from @dr-vortex to @james-pre. Please update your comment, and I can delete this one. I'm writing this comment when I can't make the change myself. |
This is a really cool project, though it's difficult to use a part of a project due to the lengthy build and compilation. Could we have Emception as a library?
For example (on a website):
A few things to note:
Why do we need a library?
The text was updated successfully, but these errors were encountered: