Results 1 to 4 of 4

Thread: Qt and Web Assembly - Installation, running examples and openCV

  1. #1
    Join Date
    Jul 2020
    Posts
    11
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Qt and Web Assembly - Installation, running examples and openCV

    Hi,
    I've searched in the documentation and a few pages here how to solve my issues, without luck.

    First, I have an issue when running any example, it compiles, open a browers and says :
    - Qt for WebAssembly: [project]
    Application exit (RuntimeError: Aborted('specialHTMLTargets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)))
    Did not find what causes this in the FAQ, and even ChatGPT lied to me.

    Example, a very simple hello world program :
    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    3. #include <QTranslator>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QTranslator translator;
    9. if (!translator.load("hellotr_la"))
    10. return 1;
    11.  
    12. app.installTranslator(&translator);
    13.  
    14. QPushButton hello(QPushButton::tr("Hello world!"));
    15. hello.resize(100, 30);
    16. hello.show();
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 


    Second issue is linking libraries such as opencv, it says the .dll built with mingw are "unknown file type"
    wasm-ld: error: unknown file type: C:/Dev/opencv/mingw-build/bin/libopencv_calib3d460.dll
    Thanks for any help !

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,248
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt and Web Assembly - Installation, running examples and openCV

    and even ChatGPT lied to me.


    It looks like your bug is caused by something in the Qt CMake scripts used to build Qt for WebAssembly. Check out this Qt bug report post and compare with your Qt6WasmMacros.cmake file contents.

    Second issue is linking libraries such as opencv, it says the .dll built with mingw are "unknown file type"
    Usually you link to the ".lib" file, not the ".dll" file. DLLs are used only at runtime, not at compile and link time.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2020
    Posts
    11
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: Qt and Web Assembly - Installation, running examples and openCV

    Quote Originally Posted by d_stranz View Post


    It looks like your bug is caused by something in the Qt CMake scripts used to build Qt for WebAssembly. Check out this Qt bug report post and compare with your Qt6WasmMacros.cmake file contents.
    I found a Qt5WasmMacros.cmake in the folder wasm_32/lib/cmake/Qt6Core, here it is :
    Qt Code:
    1. # Copy in Qt HTML/JS launch files for apps.
    2. function(_qt_internal_wasm_add_target_helpers target)
    3. /----- (some stuff here) -----/
    4.  
    5. function(_qt_internal_add_wasm_extra_exported_methods target)
    6. get_target_property(wasm_extra_exported_methods "${target}" QT_WASM_EXTRA_EXPORTED_METHODS)
    7.  
    8. if(NOT wasm_extra_exported_methods)
    9. set(wasm_extra_exported_methods ${QT_WASM_EXTRA_EXPORTED_METHODS})
    10. endif()
    11.  
    12. if(wasm_extra_exported_methods)
    13. target_link_options("${target}" PRIVATE
    14. "SHELL:-s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,${wasm_extra_exported_methods}"
    15. )
    16. else()
    17. # an errant dangling comma will break this
    18. target_link_options("${target}" PRIVATE
    19. "SHELL:-s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16"
    20. )
    21. endif()
    22. endfunction()
    To copy to clipboard, switch view to plain text mode 
    I don't know if it get used by make, by the compiler or not, or at which state. I usually use cmake but I simply try to understand the basics of it until it works.

    Am I supposed to copy this file to "HTML/JS Launch file (??)" or is that what this file do ?

    (that's true for .dll, I'll have a look later at why it links them instead of lnking libs.)
    Last edited by d_stranz; 18th February 2023 at 17:46. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,248
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt and Web Assembly - Installation, running examples and openCV

    I don't know if it get used by make, by the compiler or not, or at which state. I usually use cmake but I simply try to understand the basics of it until it works.
    This file is used by cmake as it generates the Makefile for Qt WebAssembly.

    I think you can define a cmake variable QT_WASM_EXTRA_EXPORTED_METHODS and set it to "specialHTMLTargets" (or append this to what is there if it is already defined, separated by a comma). The script above looks for this variable and appends the contents to the wasm_extra_exported_methods variable, which in turn adds it to the "SHELL: -s" link options.

    You might find the QT_WASM... variable defined (but possibly empty) in one of the top-level CMakeLists.txt files for Qt WebAssembly.

    Edit: Now that I changed your QUOTE tags to CODE tags, I can see that what you pasted was a function definition. I was misreading it a bit prior to that. Instead of a variable, you may have to look for a call to set_target_properties() or set_property( TARGET ... ) that contains the QT_WASM... name and modify that. See this stackoverflow post about how to use set_property.

    My Qt 5.14.2 distribution doesn't seem to have any of the Qt WebAssembly source files, so I can't really check this out.
    Last edited by d_stranz; 18th February 2023 at 18:00.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Running Qwt examples on Android ?
    By esutton in forum Qwt
    Replies: 3
    Last Post: 3rd September 2014, 10:28
  2. Running QWT Examples in Mac OS X
    By lynchkp in forum Qwt
    Replies: 7
    Last Post: 7th November 2012, 23:46
  3. QtCreate 2.3.0 and Opencv 2.3.0 installation
    By MohdRash in forum Newbie
    Replies: 3
    Last Post: 31st October 2011, 21:13
  4. Prblem in Building and running Examples.
    By Tarun in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2010, 14:45
  5. Running Qt Creator examples
    By Saman in forum Newbie
    Replies: 5
    Last Post: 5th May 2009, 21:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.