trzecieu / emscripten-docker

Docker image with Emscripten to compile ASM.js and WebAssembly
MIT License
97 stars 29 forks source link

Exported functions fail due lack of Perl JSON Module #32

Closed dbkr closed 6 years ago

dbkr commented 6 years ago

I'm attempting to build an emscripten-based project that uses the -s EXPORTED_FUNCTIONS option to emcc but it fails with:

perl -MJSON -ne '$f{"_$1"}=1 if /(olm_[^( ]*)\(/; END { @f=sort keys %f; print encode_json \@f }' [header files] > javascript/exported_functions.json.tmp
Can't locate JSON.pm in @INC (you may need to install the JSON module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .).

It looks like adding libjson-perl to the list of installed apt packages is necessary to use the -s EXPORTED_FUNCTIONS option?

trzecieu commented 6 years ago

Hi! Can you please let me know how I can simply reproduce this issue?


I've tested

emcc main.cpp -s EXPORTED_FUNCTIONS=['_a']

on

#include <iostream>
int main() {
    std::cout << "asdAS\n";
    return 1;
}

int a() {
    return 2;
}

And it worked just fine (emscripten-slim:latest)

dbkr commented 6 years ago

Ah, sorry - it's part of our Makefile that I hadn't noticed, it's not part of emscripten itself. Thanks for checking!