9

Actually I'm using GSL in my c++ program. I've referred to the emscripten documentation but got nothing. This is what I see in the documentation, which makes no sense:

# For example, consider the case where a project “project” uses a library “libstuff”:
# Compile libstuff to bitcode
./emconfigure ./configure
./emmake make

# Compile project to bitcode
./emconfigure ./configure
./emmake make

# Compile the library and code together to HTML
emcc project.bc libstuff.bc -o final.html

(Isn't there something wrong with the documentation?) And it says nothing about how to use the library in javascript.

Here's the problems I have:

  1. How to build a third party library into bitcode?
  2. How to use the library in javascript?

Thanks in advance.

6
  • Can you post the commands you use to compile your program into a standard executable? Commented May 20, 2015 at 20:31
  • I think there's no excutable involved Commented May 22, 2015 at 10:10
  • I mean, if you were building your program as a standard executable, using GSL (say with gcc), then what would you do? My aim for asking this is to be able to help translate those commands into building the program using Emscripten. Commented May 22, 2015 at 10:20
  • ... Or, if you could post a very small cut down version of the program you're trying to compile, with (for example) just a main function that just calls one or two functions from GSL, and outputs a result to standard out, then answers could give you the commands to compile it. Commented May 22, 2015 at 11:16
  • I've just realised I might have misunderstood. Do you actually not have a "C++ program" that you have written, but are just wanting to call GSL functions from Javascript? Commented May 22, 2015 at 11:54

1 Answer 1

2

You will need access to the C/C++ source code of the third party library and compile it using Emscripten before you can link with it in your program.

Once you have compiled the third party library with Emscripten, you can now statically link with it and use it normally in your C/C++ program, which also needs to be built with Emscripten.

If you don't have your own C/C++ program, Emscripten 1.32.2 now supports building dynamic libraries into Javascript modules that you can use on your web page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.