Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Calling C++ function from JavaScript through Qt Webassembly
Forum Updated to NodeBB v4.3 + New Features

Calling C++ function from JavaScript through Qt Webassembly

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
3 Posts 2 Posters 793 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ihmc
    wrote on last edited by
    #1

    Re: Calling C++ function from JavaScript through Webassembly

    Same issue.

    extern "C" {
        int other_function(int value){
            qDebug() << value;
            return 0;
        }
    }
    

    Even with

    -s EXPORTED_FUNCTIONS='["_other_function"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]'
    

    and in the compiled YOURAPP.html

    other_func = Module.cwrap("other_function", "number", ["number"])
    other_func(1)
    

    There error still exist

    Uncaught TypeErorr : Module.cwrap is not a function
    
    
    Any help ?
    1 Reply Last reply
    0
    • lorn.potterL Offline
      lorn.potterL Offline
      lorn.potter
      wrote on last edited by lorn.potter
      #2

      I prefer using the embind method.

      https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#embind

      Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
      Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

      I 1 Reply Last reply
      0
      • lorn.potterL lorn.potter

        I prefer using the embind method.

        https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#embind

        I Offline
        I Offline
        ihmc
        wrote on last edited by
        #3

        @lorn-potter Thanks for the information. Yet <emscripten.h> cannot be found!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved