Closed Ycblue closed 5 years ago
You can compile your cpp file to a BC file first by emcc -c xxx.cpp -o xxx.bc
And Link all the BC files together using emcc a.bc b.bc c.bc -o result.js
Thanks for the response! I did try that and it compiles. Sadly it throws a different issue. I have a folder "Models" that is attached with the --preload-file flag. It should generate a output.data file that is linked with the final output.js. When compiling to .bc first it isn't generated at all. And including the flags in the second compile command doesn't work either.
Could you show me your makefile?
It would be great if I can see the log too
On Fri, Jun 7, 2019, 12:27 AM Ycblue notifications@github.com wrote:
Thanks for the response! I did try that and it compiles. Sadly it throws a different issue. I have a folder "Models" that is attached with the --preload-file flag. It should generate a output.data file that is linked with the final output.js. When compiling to .bc first it isn't generated at all. And including the flags in the second compile command doesn't work either.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emscripten-core/emscripten/issues/8750?email_source=notifications&email_token=ABLPC3CLQDSBPVBP7CYBSCLPZD7EBA5CNFSM4HU7P422YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXCVTAI#issuecomment-499472769, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLPC3H7DNW5ZV4B6WS7GXLPZD7EBANCNFSM4HU7P42Q .
I haven't made a full make file yet, but this is the script I use to compile:
rm output.data -rf
rm build/ -rf
mkdir build
cd build
emcc ../NRRDCoffee.cpp -o NRRDCoffee.bc \
-s WASM=3 -std=c++17 -s NO_EXIT_RUNTIME \
-s FULL_ES3=1 -s USE_WEBGL2=1 -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1 \
-s LINKABLE=1 -s EXPORT_ALL=1 \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" \
--emrun --llvm-opts 2 -O2 -s ASSERTIONS=2 -s DEMANGLE_SUPPORT=1 \
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \
--embed-file ../assets --preload-file ../Models \
emcc NRRDCoffee.bc ../libassimp.bc -o output.js
xcopy output.data ..
emrun --no_browser --port 8080 ../index.html
This compiles, but it doesn't generate the output.data file and the browser throws this error:
TypeError: Module.stringToNewUTF8 is not a function
I just tried to move all the flags into the second emcc command like this:
rm output.data -rf
rm build/ -rf
mkdir build
cd build
emcc ../NRRDCoffee.cpp -o NRRDCoffee.bc \
emcc NRRDCoffee.bc ../libassimp.bc -o output.js
-s WASM=3 -std=c++17 -s NO_EXIT_RUNTIME \
-s FULL_ES3=1 -s USE_WEBGL2=1 -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1 \
-s LINKABLE=1 -s EXPORT_ALL=1 \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" \
--emrun --llvm-opts 2 -O2 -s ASSERTIONS=2 -s DEMANGLE_SUPPORT=1 \
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \
--embed-file ../assets --preload-file ../Models \
xcopy output.data ..
emrun --no_browser --port 8080 ../index.html
This way the output.data is generated but the dependencies are all wrong:
RangeError: invalid array length
output.js:216:26
still waiting on run dependencies: output.js:1712:13
dependency: fp /Models/180501-a0.stl output.js:1714:11
dependency: fp /Models/Closed Left femur (autoseg refined).ply output.js:1714:11
dependency: fp /Models/deer.obj output.js:1714:11
dependency: fp /Models/Pic3D.nrrd output.js:1714:11
dependency: fp /Models/S130128_hip.nrrd output.js:1714:11
dependency: fp /Models/suzanne.obj output.js:1714:11
dependency: fp /Models/test.nrrd output.js:1714:11
dependency: datafile_output.data output.js:1714:11
(end of list)
Oh I see. The data embedding flag should be placed after the second emcc command *(linking stage)
Give it a try
On Fri, Jun 7, 2019, 12:36 AM Ycblue notifications@github.com wrote:
I haven't made a full make file yet, but this is the script I use to compile:
rm output.data -rf rm build/ -rf mkdir build cd build
emcc ../NRRDCoffee.cpp -o NRRDCoffee.bc \ -s WASM=3 -std=c++17 -s NO_EXIT_RUNTIME \ -s FULL_ES3=1 -s USE_WEBGL2=1 -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1 \ -s LINKABLE=1 -s EXPORT_ALL=1 \ -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" \ --emrun --llvm-opts 2 -O2 -s ASSERTIONS=2 -s DEMANGLE_SUPPORT=1 \ -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \ --embed-file ../assets --preload-file ../Models \
emcc NRRDCoffee.bc ../libassimp.bc -o output.js
xcopy output.data .. emrun --no_browser --port 8080 ../index.html
This compiles, but it doesn't generate the output.data file and the browser throws this error: TypeError: Module.stringToNewUTF8 is not a function
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emscripten-core/emscripten/issues/8750?email_source=notifications&email_token=ABLPC3CRK52BXIRJJOSUAN3PZEAE7A5CNFSM4HU7P422YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXCWHLI#issuecomment-499475373, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLPC3EMLNQNZ3MPBYR2ZIDPZEAE7ANCNFSM4HU7P42Q .
Oh I see. The data embedding flag should be placed after the second emcc command *(linking stage) Give it a try
What about the other flags?
I guess a lazy solution is to just keep the flags for both commands. Hahaha
On Fri, Jun 7, 2019, 12:43 AM Ycblue notifications@github.com wrote:
Oh I see. The data embedding flag should be placed after the second emcc command *(linking stage) Give it a try
What about the other flags?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emscripten-core/emscripten/issues/8750?email_source=notifications&email_token=ABLPC3FP5H7AYZTFP7VPZZDPZEA5VA5CNFSM4HU7P422YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXCWXDY#issuecomment-499477391, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLPC3DAEOZ4ESIZWQQC7C3PZEA5VANCNFSM4HU7P42Q .
Haha, okay I tried, but it also failed:
Supported GLSL version is OpenGL ES GLSL ES 3.00 (WebGL GLSL ES 3.00). output.js:1:33072986
Compiling vertex-shader. output.js:1:33072986
Compiling fragment-shader. output.js:1:33072986
Compile complete. output.js:1:33072986
programObject linked. output.js:1:33072986
missing function: _Z10loadAssImpPKcRNSt3__26vectorItNS1_9allocatorItEEEERNS2_IN3glm5tvec3IfLNS7_9precisionE0EEENS3_ISA_EEEERNS2_INS7_5tvec2IfLS9_0EEENS3_ISF_EEEESD_ output.js:1:33073109
-1 output.js:1:33072986
-1 output.js:1:33073109
uncaught exception: abort(-1) at jsStackTrace@http://localhost:8080/build/output.js:1:1372798
stackTrace@http://localhost:8080/build/output.js:1:1372969
abort@http://localhost:8080/build/output.js:1:33071492
loadAssImp(char const*, std::__2::vector<unsigned short, std::__2::allocator<unsigned short> >&, std::__2::vector<glm::tvec3<float, (glm::precision)0>, std::__2::allocator<glm::tvec3<float, (glm::precision)0> > >&, std::__2::vector<glm::tvec2<float, (glm::precision)0>, std::__2::allocator<glm::tvec2<float, (glm::precision)0> > >&, std::__2::vector<glm::tvec3<float, (glm::precision)0>, std::__2::allocator<glm::tvec3<float, (glm::precision)0> > >&) [__Z10loadAssImpPKcRNSt3__26vectorItNS1_9allocatorItEEEERNS2_IN3glm5tvec3IfLNS7_9precisionE0EEENS3_ISA_EEEERNS2_INS7_5tvec2IfLS9_0EEENS3_ISF_EEEESD_]@http://localhost:8080/build/output.js:1:1384129
@http://localhost:8080/build/output.wasm:wasm-function[598]:0x21e2f2
Module._initGL@http://localhost:8080/build/output.js:1:32764945
ccall@http://localhost:8080/build/output.js:1:1363844
createContext@http://localhost:8080/:71:32
Module.onRuntimeInitialized@http://localhost:8080/:74:17
doRun@http://localhost:8080/build/output.js:1:33069784
run@http://localhost:8080/build/output.js:1:33070099
runCaller@http://localhost:8080/build/output.js:1:33069397
removeRunDependency@http://localhost:8080/build/output.js:1:1380350
processPackageData@http://localhost:8080/build/output.js:1:1351661
loadPackage/<@http://localhost:8080/build/output.js:1:2762
fetchRemotePackage/xhr.onload@http://localhost:8080/build/output.js:1:2349
The first part looks as it should, but the problems start with "missing function: ". I'm pretty sure I compiled the library correctly. Is there any kind of work around for including libraries?
Check where the loadassimp is from
Make sure the corresponding file has been compiled.
On Fri, Jun 7, 2019, 12:55 AM Ycblue notifications@github.com wrote:
Haha, okay I tried, but it also failed:
Supported GLSL version is OpenGL ES GLSL ES 3.00 (WebGL GLSL ES 3.00). output.js:1:33072986 Compiling vertex-shader. output.js:1:33072986 Compiling fragment-shader. output.js:1:33072986 Compile complete. output.js:1:33072986 programObject linked. output.js:1:33072986
missing function: _Z10loadAssImpPKcRNSt3__26vectorItNS1_9allocatorItEEEERNS2_IN3glm5tvec3IfLNS7_9precisionE0EEENS3_ISA_EEEERNS2_INS7_5tvec2IfLS9_0EEENS3_ISFEEEESD output.js:1:33073109 -1 output.js:1:33072986 -1 output.js:1:33073109 uncaught exception: abort(-1) at jsStackTrace@http://localhost:8080/build/output.js:1:1372798 stackTrace@http://localhost:8080/build/output.js:1:1372969 abort@http://localhost:8080/build/output.js:1:33071492 loadAssImp(char const*, std::2::vector<unsigned short, std::2::allocator
>&, std::2::vector<glm::tvec3<float, (glm::precision)0>, std::2::allocator<glm::tvec3<float, (glm::precision)0> > >&, std::2::vector<glm::tvec2<float, (glm::precision)0>, std::2::allocator<glm::tvec2<float, (glm::precision)0> > >&, std::2::vector<glm::tvec3<float, (glm::precision)0>, std::2::allocator<glm::tvec3<float, (glm::precision)0> > >&) [Z10loadAssImpPKcRNSt326vectorItNS1_9allocatorItEEEERNS2_IN3glm5tvec3IfLNS7_9precisionE0EEENS3_ISA_EEEERNS2_INS7_5tvec2IfLS9_0EEENS3_ISFEEEESD]@http://localhost:8080/build/output.js:1:1384129 @http://localhost:8080/build/output.wasm:wasm-function[598]:0x21e2f2 Module._initGL@http://localhost:8080/build/output.js:1:32764945 ccall@http://localhost:8080/build/output.js:1:1363844 createContext@http://localhost:8080/:71:32 Module.onRuntimeInitialized@http://localhost:8080/:74:17 doRun@http://localhost:8080/build/output.js:1:33069784 run@http://localhost:8080/build/output.js:1:33070099 runCaller@http://localhost:8080/build/output.js:1:33069397 removeRunDependency@http://localhost:8080/build/output.js:1:1380350 processPackageData@http://localhost:8080/build/output.js:1:1351661 loadPackage/ http://localhost:8080/build/output.js:1:1351661loadPackage/<@http://localhost:8080/build/output.js:1:2762 fetchRemotePackage/xhr.onload@http://localhost:8080/build/output.js:1:2349 http://localhost:8080/build/output.js:1:2762fetchRemotePackage/xhr.onload@http://localhost:8080/build/output.js:1:2349 The first part looks as it should, but the problems start with "missing function: ". I'm pretty sure I compiled the library correctly. Is there any kind of work around for including libraries?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/emscripten-core/emscripten/issues/8750?email_source=notifications&email_token=ABLPC3F6UWO3ZTRI5DCS2DDPZECK7A5CNFSM4HU7P422YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXCXVHA#issuecomment-499481244, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLPC3DW7EMCVHY2PYETFVLPZECK7ANCNFSM4HU7P42Q .
Well funny thing. With all the compile commands I forgot to enable loadassimp in the code XD It's still not working as I want, but hopefully its not a library include problem anymore!
Thanks for the help!
It's definitely not a library include problem anymore so I'm gonna close this issue!
Hi all, I'm having trouble including libraries in my C++ code such as AssImp and Teem. I have tried compiling the library code to .bc files, but I don't know how to properly include them in the emcc build command.
This is my current build command:
emcc ../NRRDCoffee.cpp ../libassimp.bc -o output.js \ -s WASM=3 -std=c++17 -s NO_EXIT_RUNTIME \ -s FULL_ES3=1 -s USE_WEBGL2=1 -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1 \ -s LINKABLE=1 -s EXPORT_ALL=1 \ -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" \ --emrun --llvm-opts 2 -O2 -s ASSERTIONS=2 -s DEMANGLE_SUPPORT=1 \ -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \ --embed-file ../assets --preload-file ../Models \
which obviously doesn't work, but hopefully it can provide a starting point. The headers are included and found in the main code. If anyone could give me some tipps, that would be really helpful!!