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

Using static and dynamic libraries #3713

Closed
AppPlusPlus opened this issue Aug 25, 2015 · 9 comments
Closed

Using static and dynamic libraries #3713

AppPlusPlus opened this issue Aug 25, 2015 · 9 comments
Labels

Comments

@AppPlusPlus
Copy link

Hi. I have seen that the support for linking has been changed over time. I have a general question. Which one of these are supported in the latest version?

1- Using .a static libraries?
2- Using .so shared libraries?
3- Using .lib static libraries?
4- Using .dll dynamic libraries?

So, if a library is created by another gcc compiler, then would it be possible to link it with a emscripten project?

@kripken
Copy link
Member

kripken commented Aug 25, 2015

The docs at https://github.com/kripken/emscripten/wiki/Linking are up to date.

gcc can't emit LLVM bitcode or JS, so we can't link to that.

@AppPlusPlus
Copy link
Author

Probably I didn't ask my question clearly. If you have a C++ library and a C++ user code, would it be possible to link them together? I mean, in principle, it should be possible to define a JavaScript wrapper around unresolved functions and use their definition from the C++ library. Isn't it?

@kripken
Copy link
Member

kripken commented Aug 26, 2015

Yes, you can statically and dynamically link a C++ library and C++ user code. Statically is trivial, it's just bitcode that LLVM links for us. Dynamically, see for example in the test suite we have test_dylink_class that links a simple C++ class.

@AppPlusPlus
Copy link
Author

I think we are talking about different things. By library, I mean I don't have the source. I cannot recompile it. it is just a C++ dll. Is it something similar to glue code in node.js available?

@kripken
Copy link
Member

kripken commented Aug 27, 2015

A C++ DLL containing x86 binary code? Emscripten doesn't know how to interface with that.

A C++ DLL containing LLVM IR - i.e., an Emscripten-compiled bitcode file - would be fine of course.

@0-issue
Copy link

0-issue commented Mar 1, 2018

I guess what AppPlusPlus is asking is: If I write a new C++ function-A that calls another function-B and function-B resides in a dynamic shared library compiled from GCC (source code of function-B is unavailable, it was compiled by GCC into a dynamic library eons ago, and we have the headers of course), will this scheme work with emscripten?

Thanks,

AM

@kripken
Copy link
Member

kripken commented Mar 1, 2018

No, function-B is in x86 or some other native format, so emscripten can't compile code to work with it. (For that to work, you would need an x86-to-JS or x86-to-wasm compiler, which is possible in theory but a very large amount of work.)

@pixelherodev
Copy link

"A C++ DLL containing LLVM IR - i.e., an Emscripten-compiled bitcode file - would be fine of course." Really glad I found this issue, thanks!

Nice work on this project, it's amazing!

@stale
Copy link

stale bot commented Sep 23, 2019

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Sep 23, 2019
@sbc100 sbc100 closed this as completed Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants