简体   繁体   English

使用 Emscripten 构建时如何包含库 header?

[英]How to include library header when building with Emscripten?

I am trying to build codecbox.js on Ubuntu 18.04, which involves building FFmpeg with emcc.我正在尝试在 Ubuntu 18.04 上构建codecbox.js ,这涉及使用 emcc 构建 FFmpeg。 I have been stuck with the misleading libmp3lame >= 3.98.3 not found error .我一直被误导性的libmp3lame >= 3.98.3 not found错误困扰 In my case, there is no problem with libmp3lame installation.就我而言,libmp3lame 安装没有问题。 After further investigation into FFmpeg's configure script, I found out that the following test file failed to compile with emcc:进一步排查FFmpeg的configure脚本后,发现下面的测试文件用emcc编译失败:

#include <lame/lame.h>
#include <stdint.h>

long check_lame_set_VBR_quality(void) { return (long) lame_set_VBR_quality; }
int main(void) {
    int ret = 0;
    ret |= ((intptr_t)check_lame_set_VBR_quality) & 0xFFFF;
    return ret;
}

I get fatal error: 'lame/lame.h' file not found .我收到fatal error: 'lame/lame.h' file not found

I found the header in /usr/include/lame so I tried compiling with emcc -I/usr/include .我在/usr/include/lame中找到了 header 所以我尝试使用emcc -I/usr/include进行编译。 This removed the error but introduced plenty of other errors.这消除了错误,但引入了许多其他错误。

Then I read ( for example here ) that I should not use local system headers, which happens when I add option -I/usr/include .然后我读到( 例如这里)我不应该使用本地系统头文件,当我添加选项-I/usr/include时会发生这种情况。

So what is the proper way to ensure emcc finds my library header whilst using Emscripten bundled system headers provided within the SDK?那么,在使用 SDK 中提供的 Emscripten 捆绑系统头文件时,确保 emcc 找到我的库 header 的正确方法是什么?

/usr/include/lame sounds like you are building it with the system installation. /usr/include/lame听起来您正在使用系统安装来构建它。 You are not supposed to build an emscriten module with any system-wide packages though.但是,您不应该使用任何系统范围的包构建 emscriten 模块。 Imagine you are distributing the emscripten-compiled package to the web, not to someone else's desktop.想象一下,您将 emscripten 编译的 package 分发到 web,而不是其他人的桌面。 You probably want to get the source of ffmpeg and other related libraries manually.您可能想手动获取 ffmpeg 和其他相关库的源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM