openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

Emscripten make issue

Open liquidzym opened this issue 1 year ago • 10 comments

setting up the latest the emsdk and env according to the page https://openframeworks.cc/setup/emscripten/ the xcode version which is 15.2(15c500b)

the nightly build version and 0.12.0 both with this error

clang++: error: unknown argument: '--gc-sections' em++: error: '/Users/liquid/Desktop/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/Users/liquid/Desktop/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -isystem /Users/liquid/Desktop/emsdk/upstream/emscripten/cache/sysroot/include/freetype2 -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O3 -Wl --gc-sections /Users/liquid/Desktop/of_v20240228_osx_release/libs/openFrameworksCompiled/lib/emscripten/libopenFrameworks.bc -c -o /var/folders/63/p36n6bnn21lc5x59z00d7nqw0000gn/T/emscripten_temp_5ucj2s0_/libopenFrameworks_0.o' failed (returned 1) make[1]: *** [bin/em/graphicsExample/index.html] Error 1 make: *** [Release] Error 2 emmake: error: 'make' failed (returned 2)

liquidzym avatar Feb 29 '24 05:02 liquidzym

I just tested as well, seems okay, hmmm lets verify your setup:

Env setup:

echo "Emscripten Download SRC"
	cd ../../
	git clone https://github.com/emscripten-core/emsdk.git
	cd emsdk
	git pull

	echo "if any issues with python - make sure to add python paths to bash environment Variables:"
  python -m pip install --upgrade pip setuptools virtualenv
  ./emsdk install latest
  ./emsdk activate latest --permanent
   ./emsdk_env.sh

And are you running a command like this in the project directory:

emmake make

danoli3 avatar Feb 29 '24 07:02 danoli3

output should be like this:

     
#de  f157i | n        e# dGeLf_iDnEeP TGHL__CDOEMPTH_CPOOMNPEONNTE2N4T    2        4                                                                            G        L        _GDLE_PDTEPTH_HC_OCMOPMOPNOENNETN2T42_4O_EOSES
      
|       |                 ^
                ^
/Users/~/SOURCE/EMSDK/emsdk/upstream/emscripten/cache/sysroot/include/GL/glext.h:325:9/Users/~/SOURCE/EMSDK/emsdk/upstream/emscripten/cache/sysroot/include/GL/glext.h:: 325:note: 9:previous definition is here 
note:   previous definition is here325 | 
#d  325 | efi#ndefe GiLn_eD EGPLT_HD_ECPOTMHP_OCNOEMNPTO2N4E N T 2 4                    0 x 8 1 A06x8
1A6      |         ^

      |         ^
4 warnings generated.
4 warnings generated.
Linking bin/em/emscripten/index.html for emscripten
/Users/~/SOURCE/EMSDK/emsdk/upstream/emscripten/em++ -o bin/em/emscripten/index.html -O3 -s TOTAL_MEMORY=134217728 --memory-init-file 1 obj/emscripten/Release/src/ofApp.o obj/emscripten/Release/src/main.o  /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundStream.o /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoPlayer.o /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundPlayer.o /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoGrabber.o /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenURLFileLoader.o /Users/~/SOURCE/openFrameworksEm/addons/obj/emscripten/Release/ofxEmscripten/src/ofxAppEmscriptenWindow.o  /Users/~/SOURCE/openFrameworksEm/libs/openFrameworksCompiled/lib/emscripten/libopenFrameworks.bc   -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s FULL_ES2 -sFULL_ES3=1 -s USE_PTHREADS=0 --js-library /Users/~/SOURCE/openFrameworksEm/addons/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js --js-library /Users/~/SOURCE/openFrameworksEm/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js --shell-file /Users/~/SOURCE/openFrameworksEm/libs/openFrameworksCompiled/project/emscripten/template.html /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a /Users/~/SOURCE/openFrameworksEm/libs/boost/lib/emscripten/libboost_system.a /Users/~/SOURCE/openFrameworksEm/libs/boost/lib/emscripten/libboost_filesystem.a /Users/~/SOURCE/openFrameworksEm/libs/pugixml/lib/emscripten/libpugixml.bc /Users/~/SOURCE/openFrameworksEm/libs/tess2/lib/emscripten/libtess2.a /Users/~/SOURCE/openFrameworksEm/libs/uriparser/lib/emscripten/liburiparser.a    
em++: warning: --memory-init-file is only supported with -sWASM=0 [-Wunsupported]
wasm-ld: warning: function signature mismatch: StrIODecTerm
>>> defined as (i32) -> void in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(JXRTranscode.o)
>>> defined as (i32) -> i32 in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(strdec.o)

wasm-ld: warning: function signature mismatch: StrIOEncTerm
>>> defined as (i32) -> void in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(JXRTranscode.o)
>>> defined as (i32) -> i32 in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(strenc.o)

wasm-ld: warning: function signature mismatch: encodeMB
>>> defined as (i32, i32, i32) -> void in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(JXRTranscode.o)
>>> defined as (i32, i32, i32) -> i32 in /Users/~/SOURCE/openFrameworksEm/libs/FreeImage/lib/emscripten/libfreeimage.a(strenc.o)

     compiling done
     to launch the application on the default browser, run:

     emrun bin/em/emscripten
     
     some browsers, like safari, don't support webgl
     
emrun has automatically found the following browsers in the default install locations on the system:

  - chrome: Google Chrome 
  - safari: Apple Safari 

You can pass the --browser <id> option to launch with the given browser above.
Even if your browser was not detected, you can use --browser /path/to/browser/executable to launch with that browser.

```

danoli3 avatar Feb 29 '24 07:02 danoli3

emm,wired ,still not working,i'm sure i'm setting up everything this is the lastest step

liquid@liquiddeMacBook-Pro graphicsExample % cd /Users/liquid/Desktop/emsdk liquid@liquiddeMacBook-Pro emsdk % ./emsdk_env.sh Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1) Setting environment variables: liquid@liquiddeMacBook-Pro emsdk % cd /Users/liquid/Desktop/of_v20240228_osx_release/examples/graphics/graphicsExample liquid@liquiddeMacBook-Pro graphicsExample % emmake make make: make Compiling OF library for Release Done!

Compiling graphicsExample for Release Linking bin/em/graphicsExample/index.html for emscripten /Users/liquid/Desktop/emsdk/upstream/emscripten/em++ -o bin/em/graphicsExample/index.html -O3 -s TOTAL_MEMORY=134217728 --memory-init-file 1 obj/emscripten/Release/src/ofApp.o obj/emscripten/Release/src/main.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundStream.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoPlayer.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundPlayer.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoGrabber.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenURLFileLoader.o /Users/liquid/Desktop/of_v20240228_osx_release/addons/obj/emscripten/Release/ofxEmscripten/src/ofxAppEmscriptenWindow.o /Users/liquid/Desktop/of_v20240228_osx_release/libs/openFrameworksCompiled/lib/emscripten/libopenFrameworks.bc -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s FULL_ES2 -sFULL_ES3=1 -s USE_PTHREADS=0 --js-library /Users/liquid/Desktop/of_v20240228_osx_release/addons/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js --js-library /Users/liquid/Desktop/of_v20240228_osx_release/addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js --shell-file /Users/liquid/Desktop/of_v20240228_osx_release/libs/openFrameworksCompiled/project/emscripten/template.html /Users/liquid/Desktop/of_v20240228_osx_release/libs/FreeImage/lib/emscripten/libfreeimage.a /Users/liquid/Desktop/of_v20240228_osx_release/libs/boost/lib/emscripten/libboost_system.a /Users/liquid/Desktop/of_v20240228_osx_release/libs/boost/lib/emscripten/libboost_filesystem.a /Users/liquid/Desktop/of_v20240228_osx_release/libs/pugixml/lib/emscripten/libpugixml.bc /Users/liquid/Desktop/of_v20240228_osx_release/libs/tess2/lib/emscripten/libtess2.a /Users/liquid/Desktop/of_v20240228_osx_release/libs/uriparser/lib/emscripten/liburiparser.a
clang++: error: unknown argument: '--gc-sections' em++: error: '/Users/liquid/Desktop/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/Users/liquid/Desktop/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -isystem /Users/liquid/Desktop/emsdk/upstream/emscripten/cache/sysroot/include/freetype2 -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O3 -Wl --gc-sections /Users/liquid/Desktop/of_v20240228_osx_release/libs/openFrameworksCompiled/lib/emscripten/libopenFrameworks.bc -c -o /var/folders/63/p36n6bnn21lc5x59z00d7nqw0000gn/T/emscripten_temp_cpygkmyl/libopenFrameworks_0.o' failed (returned 1) make[1]: *** [bin/em/graphicsExample/index.html] Error 1 make: *** [Release] Error 2 emmake: error: 'make' failed (returned 2)

any ideas? btw,thank you so much for looking into it

liquidzym avatar Mar 01 '24 05:03 liquidzym

It should work with: https://github.com/openframeworks/openFrameworks/pull/7909

Jonathhhan avatar Mar 19 '24 17:03 Jonathhhan

great,thank you so much @Jonathhhan

liquidzym avatar Mar 21 '24 11:03 liquidzym

I still have problems with using pugixml, something like xmlExample, svgExample, pugiXmlExample.

I tried to delete --gc-sections from config.emscripten.default.mk, and then I got this error:

error: expected top-level entity 1 | <U+0000>asm<U+0001><U+0000><U+0000><U+0000><U+0001><B0><81><80><80><U+0000><U+001B><U+0002><U+007F><U+007F><U+0001><U+007F><U+0003><U+007F><U+007F><U+007F><U+0000><U+0004><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F><U+0003><U+007F><U+007F><U+007F><U+0001><U+007F><U+0004><U+007F><U+007F><U+007F><U+007F><U+0000><U+0001><U+007F><U+0001><U+007F><U+0001><U+007F><U+0000><U+0002><U+007F>|<U+0001>|<U+0002><U+007F><U+007F><U+0001>|<U+0002><U+007F>}<U+0001>}<U+0002><U+007F>~<U+0001>~<U+0003><U+007F>~~<U+0001>~<U+0005><U+007F><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F><U+0002><U+007F>|<U+0001><U+007F><U+0002><U+007F>}<U+0001><U+007F><U+0002><U+007F>~<U+0001><U+007F><U+0002><U+007F><U+007F><U+0000><U+0006><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0000>` | ^ 1 error generated.

I tried to change pugixml.bc to pugixml.o, but it didn't work. However the ones that don't use pugixml have no problem.

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.56 (cf90417346b78455089e64eb909d71d091ecc055)

azuremous avatar Apr 11 '24 04:04 azuremous

I downloaded the pugixml library and created a new .bc file with this command: emcc -c pugixml.cpp -o pugixml.bc -emit-llvm I also removed -Wl,--gc-sections from config.emscripten.default.mk, and it works now. (-Wl show this warning. warning: unknown warning option '-Wl' [-Wunknown-warning-option])

azuremous avatar Apr 11 '24 05:04 azuremous

@azuremous it should be solved here: https://github.com/openframeworks/apothecary/pull/367

I also removed -Wl,--gc-sections from config.emscripten.default.mk, and it works now.

Was it not working or just showing the warning?

Jonathhhan avatar Apr 11 '24 13:04 Jonathhhan

@Jonathhhan The '-WL' option only displayed a warning, but the '--gc-sections' option resulted in an error, so I removed it.

azuremous avatar Apr 12 '24 01:04 azuremous

@azuremous alright, added that to the PR https://github.com/openframeworks/openFrameworks/pull/7909

Jonathhhan avatar Apr 12 '24 01:04 Jonathhhan

I guess, this issue is solved...

Jonathhhan avatar May 19 '24 01:05 Jonathhhan

OK,i think this is working, just tested with nightly osx verion, but got another new issue,i'm closing this one open another ,thank you so much

liquidzym avatar May 21 '24 11:05 liquidzym