Emscripten on osx not working for me


#1

I’m doing some experiments to try and see what performance is like using emscripten, but I’m new to this and am hitting some walls. I tried using emmake on the examples/3d/3DPrimitivesExample , but it seems to not be linking up the ofxEmscripten addon stuff. I have been able to get the same example to load and compile in xcode. Initially I tried the osx distribution, but I got the same error, so I checked out the stable branch from github. Here’s what I am getting…

openFrameworks git:(stable) ✗ cd examples/3d/3DPrimitivesExample 
➜  3DPrimitivesExample git:(stable) ✗ emmake make                       
HOST_OS=Darwin
Compiling OF library for Release
HOST_OS=Darwin
HOST_OS=Darwin
Compiling /somefolder/openFrameworks/libs/openFrameworks/video/ofQTKitGrabber.mm
python /somefolder/emsdk/emscripten/1.37.34/em++.py -Os -DNDEBUG -mtune=native -stdlib=libc++ -Wall -fexceptions -fpascal-strings -mmacosx-version-min=10.7 -D__MACOSX_CORE__ -I/somefolder/openFrameworks/libs/FreeImage/include -I/somefolder/openFrameworks/libs/boost/include -I/somefolder/openFrameworks/libs/boost/include/boost -I/somefolder/openFrameworks/libs/cairo/include -I/somefolder/openFrameworks/libs/cairo/include/cairo -I/somefolder/openFrameworks/libs/fmodex/include -I/somefolder/openFrameworks/libs/freetype/include -I/somefolder/openFrameworks/libs/freetype/include/freetype2 -I/somefolder/openFrameworks/libs/freetype/include/freetype2/config -I/somefolder/openFrameworks/libs/freetype/include/freetype2/internal -I/somefolder/openFrameworks/libs/freetype/include/freetype2/internal/services -I/somefolder/openFrameworks/libs/glew/include -I/somefolder/openFrameworks/libs/glew/include/GL -I/somefolder/openFrameworks/libs/glfw/include -I/somefolder/openFrameworks/libs/glfw/include/GLFW -I/somefolder/openFrameworks/libs/glu/include -I/somefolder/openFrameworks/libs/glut/include -I/somefolder/openFrameworks/libs/kiss/include -I/somefolder/openFrameworks/libs/openssl/include -I/somefolder/openFrameworks/libs/openssl/include/openssl -I/somefolder/openFrameworks/libs/poco/include -I/somefolder/openFrameworks/libs/rtAudio/include -I/somefolder/openFrameworks/libs/tess2/include -I/somefolder/openFrameworks/libs/utf8cpp/include -I/somefolder/openFrameworks/libs/utf8cpp/include/utf8 -I/somefolder/openFrameworks/libs/openFrameworks -I/somefolder/openFrameworks/libs/openFrameworks/3d -I/somefolder/openFrameworks/libs/openFrameworks/video -I/somefolder/openFrameworks/libs/openFrameworks/types -I/somefolder/openFrameworks/libs/openFrameworks/app -I/somefolder/openFrameworks/libs/openFrameworks/utils -I/somefolder/openFrameworks/libs/openFrameworks/math -I/somefolder/openFrameworks/libs/openFrameworks/gl -I/somefolder/openFrameworks/libs/openFrameworks/communication -I/somefolder/openFrameworks/libs/openFrameworks/events -I/somefolder/openFrameworks/libs/openFrameworks/graphics -I/somefolder/openFrameworks/libs/openFrameworks/sound -x objective-c++ -std=c++11 -MMD -MP -MF /somefolder/openFrameworks/libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofQTKitGrabber.d -MT/somefolder/openFrameworks/libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofQTKitGrabber.o -o /somefolder/openFrameworks/libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofQTKitGrabber.o -c /somefolder/openFrameworks/libs/openFrameworks/video/ofQTKitGrabber.mm
clang++: warning: argument unused during compilation: '-mmacosx-version-min=10.7' [-Wunused-command-line-argument]
In file included from /somefolder/openFrameworks/libs/openFrameworks/video/ofQTKitGrabber.mm:2:
In file included from /somefolder/openFrameworks/libs/openFrameworks/video/ofQTKitGrabber.h:5:
In file included from /somefolder/openFrameworks/libs/openFrameworks/ofMain.h:89:
/somefolder/openFrameworks/libs/openFrameworks/sound/ofSoundStream.h:20:11: fatal error: 'ofxEmscriptenSoundStream.h' file not found
        #include "ofxEmscriptenSoundStream.h"
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
make[2]: *** [/somefolder/openFrameworks/libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofQTKitGrabber.o] Error 1
make[1]: *** [Release] Error 2
make: *** [Release] Error 2

Some extra details

➜  3DPrimitivesExample git:(stable) ✗ ls ../../../addons/ofxEmscripten/src/   
ofxAppEmscriptenWindow.cpp     ofxEmscriptenSoundPlayer.h     ofxEmscriptenURLFileLoader.cpp ofxEmscriptenVideoGrabber.h
ofxAppEmscriptenWindow.h       ofxEmscriptenSoundStream.cpp   ofxEmscriptenURLFileLoader.h   ofxEmscriptenVideoPlayer.cpp
ofxEmscriptenSoundPlayer.cpp   ofxEmscriptenSoundStream.h     ofxEmscriptenVideoGrabber.cpp  ofxEmscriptenVideoPlayer.h
➜  openFrameworks git:(stable) ✗  xcodebuild -version
Xcode 9.2
Build version 9C40b
➜  openFrameworks git:(stable) ✗ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.3
BuildVersion:	17D102

➜  openFrameworks git:(stable) ✗ emsdk list

The following precompiled tool packages are available for download:
           clang-nightly-e1.37.34-2018_02_17_19_38-64bit
           clang-nightly-e1.37.34-2018_02_17_21_02-64bit
           clang-e1.30.0-64bit      
           clang-e1.34.1-64bit      
           clang-e1.35.0-64bit      
           clang-e1.37.1-64bit      
           clang-e1.37.33-64bit     
     *     clang-e1.37.34-64bit     	INSTALLED
           node-4.1.1-64bit         
     *     node-8.9.1-64bit         	INSTALLED
           spidermonkey-37.0.1-64bit
           spidermonkey-nightly-2015-04-12-64bit
           emscripten-1.30.0        
           emscripten-1.34.1        
           emscripten-1.35.0        
           emscripten-1.37.1        
           emscripten-1.37.33       
     *     emscripten-1.37.34       	INSTALLED
           emscripten-nightly-1.37.34-2018_02_20_19_53
           emscripten-nightly-1.37.34-2018_02_20_22_08
           crunch-1.04              

The following tools can be compiled from source:
           clang-tag-e1.37.34-32bit 
           clang-tag-e1.37.35-32bit 
           clang-tag-e1.37.34-64bit 
           clang-tag-e1.37.35-64bit 
           clang-incoming-32bit     
           clang-incoming-64bit     
           clang-master-32bit       
           clang-master-64bit       
           emscripten-tag-1.37.34-32bit
           emscripten-tag-1.37.35-32bit
           emscripten-tag-1.37.34-64bit
           emscripten-tag-1.37.35-64bit
           binaryen-tag-1.37.34-32bit
           binaryen-tag-1.37.35-32bit
           binaryen-tag-1.37.34-64bit
           binaryen-tag-1.37.35-64bit
           emscripten-incoming-32bit
           emscripten-master-32bit  
           emscripten-incoming-64bit
           emscripten-master-64bit  
           binaryen-master-32bit    
           binaryen-master-64bit    

The following precompiled SDKs are available for download: (Run "git pull" followed by "./emsdk update-tags" to pull in the latest list)
         sdk-nightly-1.37.34-2018_02_17_19_38-64bit
         sdk-nightly-1.37.34-2018_02_17_21_02-64bit
         sdk-1.30.0-64bit         
         sdk-1.34.1-64bit         
         sdk-1.35.0-64bit         
         sdk-1.37.33-64bit        
    *    sdk-1.37.34-64bit        	INSTALLED

The following SDKs can be compiled from source:
         sdk-incoming-64bit       
         sdk-master-64bit         
         sdk-tag-1.37.34-64bit    
         sdk-tag-1.37.35-64bit    

Items marked with * are activated for the current user.

To access the historical archived versions, type 'emsdk list --old'

#2

I guess my question is, is this a general bug? I’m following the example from http://openframeworks.cc/setup/emscripten/
I’m about 15 years rusty on C++. What would be the approach to fix the missing paths? Ultimately, what I want to do is try and see what performance is like for an emscripten converted dlib face tracker. It seems like openFrameworks could do some of the heavy lifting for emscripten, and there are existing addons that port it in:
https://github.com/HalfdanJ/ofxFaceTracker2
https://github.com/bakercp/ofxDlib

Does that seem like a sensible approach?


#3

Here’s the instructions I used to get emscripten working on macOS (below).

As for the dlib w/ emscripten. You’ll just have to try it and see if it’s fast!

Anyway …

Download and unpack emscripten.

curl -LO https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz && tar xvf emsdk-portable.tar.gz

cd emsdk-portable/

Initialize emscripten.

./emsdk update
./emsdk install latest
./emsdk activate latest

Set up your environement.

source ./emsdk_env.sh

Set MAKEFLAGS to make it compile faster (optional).

export MAKEFLAGS="-j8 -s"

Get the latest version of openFrameworks.

git clone --depth=1 https://github.com/openFrameworks/openFrameworks.git

cd openFrameworks

Install openFrameworks libraries for emscripten.

scripts/emscripten/./download_libs.sh

Go to an example:

cd examples/3d/3DPrimitivesExample/

Copy a MAKEFILE into the example:

cp ../../../scripts/templates/emscripten/Makefile .

Build the project:

emmake make

Run the project.

emrun bin/3DPrimitivesExample.html


Emscripten Status
#4

hi,

I had the same problem, but got it to compile using the master branch version of openframeworks. – thx @bakercp

however emrun bin/3DPrimitivesExample.html fails:

Executing open -a Safari http://localhost:6931/3DPrimitivesExample.html
-1
missing function: _ZN5boost6system16generic_categoryEv
-1

#5

This did work for me, I’m not exactly sure what the weirdness was, but I appreciate the help :slight_smile:
I had a bit less luck with the addons though :confused:


#6

This was working fine until emmake make where I get the error:

zsh: command not found: emmake

Any suggestions?


#7

After you get the emscripten files, you need to add the binary executables to your environment path, including the emmake program. That’s what the “source” command is doing. You should be able to check if emmake is on your path with a command like “which emmake”, and “echo $PATH” should show you your path.


#8

Thanks for replying!

which emmake returned “emmake not found”

My path includes /Users/kevin/Projects/pap-em/emsdk-portable:/Users/kevin/Projects/pap-em/emsdk-portable/clang/e1.37.35_64bit:/Users/kevin/Projects/pap-em/emsdk-portable/node/8.9.1_64bit/bin


#9

It’s telling you it doesn’t have emmake on your path, so find it and put it on your path :slight_smile:
Here’s what that looks like for me…
which emmake
/somefolder/Documents/emsdk/emscripten/1.37.34/emmake

Maybe re-download and install it?
http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html


#10

I’ll give it a go and let you know how I get on. Thank you again! :sparkling_heart: