Just to make a few things clear:
1. I used to have a CPP thread which crashed whenever trying to create the 
thread. I removed it and then my WASM code worked perfectly.
2. (Not sure if relevant) What my code does is basically- Receive an image 
from Webcam, copy it to a JS arrayBuffer, call a callback to my CPP 
function, modify the image in cpp, return the image, and paint it on a 
canvas. With some cool AI in the process with OnnxRuntime and OpenCV 
compiled in ;)
3. I do want to use CPP threads, so to solve 1, I recompiled everything 
with -pthread, and then everything successfully recompiled.  Also some 
worker.js was created I am not sure what to do with...
4. After I thought I am finished, somehow the project forgot what 
SharedArrayBuffer is, which I guess causes all the other errors as well.
ב-יום רביעי, 19 ביולי 2023 בשעה 12:45:53 UTC+3, ‪Ronny Nissengold‬‏ כתב/ה:

> Thank you all for your support.
> I was able to successfully compile my project with pthread enabled.
> Now I face a new problem, I used Module._malloc to pass an  image from a 
> webcam into my cpp function
> For that I used the following linker 
> flags: add_link_options(-sINITIAL_MEMORY=800MB -sTOTAL_STACK=80MB -O3 -s 
> -sEXPORTED_FUNCTIONS=['_malloc','_free'] -sASSERTIONS -pthread)
>
> Now I get the following error in my console:
>
> Uncaught ReferenceError: SharedArrayBuffer is not defined
>     at blink_landmark_detector_sample.js:1:9999
>
> (index):11 Uncaught TypeError: Module._malloc is not a function
>     at _arrayToHeap ((index):11:24)
>     at HTMLVideoElement.computeFrame ((index):40:22)
>
> Any idea what happened?
> Thanks!
> Ronny
> ב-יום שלישי, 18 ביולי 2023 בשעה 16:06:32 UTC+3, tli...@google.com כתב/ה:
>
>> If you look at your CMake script, you should see that it adds -flto at 
>> some point. That’s the option you’ll want to remove. You may be able to 
>> remove it from your CMakeCache.txt file and recompile without running cmake 
>> again.
>>
>> On Tue, Jul 18, 2023 at 01:33 Ronny Nissengold <ronn...@gmail.com> wrote:
>>
>>> Thank you for your response. How do I turn off LTO?
>>>
>>> ב-יום שני, 17 ביולי 2023 בשעה 18:51:26 UTC+3, tli...@google.com כתב/ה:
>>>
>>>> This error means that some code wasn't compiled with -pthread and 
>>>> therefore is not safe to execute in a multithreaded environment. Normally 
>>>> the error message tells you which object is the culprit, but it's less 
>>>> helpful here because you're using LTO. Does the problem persist if you 
>>>> turn 
>>>> off LTO?
>>>>
>>>> On Mon, Jul 17, 2023 at 8:49 AM Ronny Nissengold <ronn...@gmail.com> 
>>>> wrote:
>>>>
>>>>> Hi all!
>>>>> I am trying to use multithreading in my project.
>>>>> I got this error when passing -pthread both to compiler and linker.
>>>>> I am using cmake.
>>>>> Any idea how to overcome this?
>>>>> Thanks!
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "emscripten-discuss" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to emscripten-disc...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/emscripten-discuss/acbc873e-078a-4082-8761-6c0322246170n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/emscripten-discuss/acbc873e-078a-4082-8761-6c0322246170n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to emscripten-disc...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/3c0a9c3c-9e56-41e4-9211-38afba0fc2c2n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/emscripten-discuss/3c0a9c3c-9e56-41e4-9211-38afba0fc2c2n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/a82fa172-4875-4b42-a1fb-ed7237ca6d9bn%40googlegroups.com.

Reply via email to