使用带有emscripten的库 [英] Using libraries with emscripten

查看:169
本文介绍了使用带有emscripten的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Emscripten,想要开始使用GLFW和其他库。我完全失去了如何建立,链接和使用其他库与Emscripten。



我已经尝试按照Emscripten网站上的说明,但他们没有帮助我。
http://kripken.github .io / emscripten-site / docs / compiling / Building-Projects.html#using-libraries



有任何地方有详细的说明如何使用图书馆与Emscripten?或者特别是GLFW?

解决方案

Emscripten提供了很少的库。这些库是在emscripten C ++代码(音频,输入,视频)上获得一些OperativeSystem功能的最低要求。




  • libc :C的标准库

  • libc ++ :C ++的标准库

  • SDL SimpleDirectmediaLayer(SDL 1.X a开源跨平台项目)

  • GLES2 :OpenGL ES 2 API

  • GLFW :GLFW 2.X



例如,在Emscripten中包含OpenGLES2的标准方法是:

  #include< GLES2 / gl2.h> 

包括GLFW时:

  #include< GL / glfw.h> 

这里有一些废话,因为如果你想使用更新版本的GLFW,因为Emscripten只提供了一个版本的库,你必须坚持下去(除非Emscripten做更新,并更新Emscripten)。



只有当库可以使用上面列出的一个(或多个)库进行编译时,您才可以编译emscripten的库。 (或者如果你知道如何包装javascript函数并通过C接口暴露它们)



此外,使用Emscripten时,生成很多膨胀代码,你可以很容易地增加几个MB的可执行文件大小:这是一个问题,如果你已经使用Boost或UBLAS。



由于GLFW不是一个自动链接的库应该链接到:

  -lglfw 



您可以在这里找到使用Emscripten的示例OpenGL项目:



https://github.com/QafooLabs/emscripten-opengl-example



您可以通过打开makefile


检查链接器标志

I have just started using Emscripten and would like to start using GLFW and other libraries. I am completely lost on how to build, link, and use other libraries with Emscripten.

I have tried following the instructions on the Emscripten site but have they haven't helped me any. http://kripken.github.io/emscripten-site/docs/compiling/Building-Projects.html#using-libraries

Is there any place with detailed instructions on how to use libraries with Emscripten? Or specifically GLFW?

解决方案

Emscripten provide itself very few libraries. Those libraries are the minimum to get some OperativeSystem functionality on emscripten C++ code (audio, input, video)

  • libc: standard library for C
  • libc++: standard library for C++
  • SDL: SimpleDirectmediaLayer (SDL 1.X a opensource cross-platform project)
  • GLES2: OpenGL ES 2 API
  • GLFW: GLFW 2.X

For example, the standard way to include OpenGLES2 in Emscripten is:

#include <GLES2/gl2.h>

While to include GLFW:

#include <GL/glfw.h>

There's some crap in that, because if you want to use the more recent version of GLFW you just can't because Emscripten provides only 1 version of the library and you have to stick with that (unless Emscripten do a update for that and you update Emscripten).

You can compile libraries for emscripten only if that libraries can be compiled using one(or more) of the libraries listed above. (or if you know how to wrap javascript funciontalities and expose them through C interface)

Also, try to avoid templates only libraries when using Emscripten, they literally generate a lot of bloat code you could easily increase executable size by several MBs: This is a problem if you were already using Boost or UBLAS.

Since GLFW is not one of the libraries that are automatically linked, you should link it with:

-lglfw

You can find an example OpenGL project using Emscripten here:

https://github.com/QafooLabs/emscripten-opengl-example

you can inspect linker flags by opening the makefile

这篇关于使用带有emscripten的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆