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. How to set up Assimp for Qt6 MinGW 64-bit
Forum Updated to NodeBB v4.3 + New Features

How to set up Assimp for Qt6 MinGW 64-bit

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
11 Posts 2 Posters 1.9k 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.
  • 8Observer88 8Observer8

    The next steps work for me (after I added C:\emsdk\upstream\emscripten to the Path variable):

    @shome said in qmake for wasm unable to find opengl libraries:

    which I have built using emscripten using the following steps:

    git clone https://github.com/assimp/assimp.git
    cd assimp && mkdir build && cd build
    emcmake cmake ..
    emmake make

    These commands generated the libassimp.a library:

    309f0a4b-2bdb-4fc8-a8de-d347579f1e55-image.png

    I try to set up this library in Qt Creator like this:

    INCLUDEPATH += "E:/libs/assimp-5.2.5/include"
    LIBS += -L"E:/libs/assimp-5.2.5/build/lib"
    LIBS += -lassimp
    

    I had this error: error: 'assimp/config.h' file not found. I solved this error by copying this file E:\libs\assimp-5.2.5\build\include\assimp\config.h to this directory: E:\libs\assimp-5.2.5\include\assimp.

    Now I have the next error :-1: error: [Makefile:69: .\load-with-assimp-wasm-opengles2-qt6-cpp.js] Error 1 But I have already built another examples with OpenGL ES 2.0 without the problem.

    load-with-assimp-wasm-opengles2-qt6-cpp.pro

    QT += core gui openglwidgets widgets
    
    win32: LIBS += -lopengl32
    
    INCLUDEPATH += "E:/libs/assimp-5.2.5/include"
    LIBS += -L"E:/libs/assimp-5.2.5/build/lib"
    LIBS += -lassimp
    
    CONFIG += c++11
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # disables all the APIs deprecated before Qt 6.0.0
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
    
    SOURCES += \
        main.cpp
    

    main.cpp

    #include <QtCore/QDebug>
    #include <QtGui/QMatrix4x4>
    #include <QtGui/QVector3D>
    #include <QtGui/QOpenGLFunctions>
    #include <QtOpenGL/QOpenGLBuffer>
    #include <QtOpenGL/QOpenGLShaderProgram>
    #include <QtOpenGLWidgets/QOpenGLWidget>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QMessageBox>
    
    #include <assimp/Importer.hpp>
    #include <assimp/postprocess.h>
    #include <assimp/scene.h>
    
    class OpenGLWidget : public QOpenGLWidget, private QOpenGLFunctions
    {
    public:
        OpenGLWidget()
        {
            setWindowTitle("Qt C++, OpenGL");
            resize(400, 400);
        }
    
    private:
        QOpenGLBuffer m_vertPosBuffer;
        QOpenGLShaderProgram m_program;
        int m_numVertices;
        QMatrix4x4 m_modelMatrix;
    
        void initializeGL() override
        {
            initializeOpenGLFunctions();
            glClearColor(0.1f, 0.1f, 0.1f, 1.f);
            glEnable(GL_DEPTH_TEST);
    
            Assimp::Importer importer;
            const char *path = "assets/models/plane-blender.dae";
            const aiScene *scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
            if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
            {
                qDebug() << "Assimp Error:" << importer.GetErrorString();
                QMessageBox::critical(this, "Assimp Error:", importer.GetErrorString());
                return;
            }
    
            m_numVertices = scene->mMeshes[0]->mNumVertices;
            float vertPositions[m_numVertices * 3];
            int vertPosIndex = 0;
            for (int i = 0; i < m_numVertices; i++)
            {
                vertPositions[vertPosIndex++] = scene->mMeshes[0]->mVertices[i].x;
                vertPositions[vertPosIndex++] = scene->mMeshes[0]->mVertices[i].y;
                vertPositions[vertPosIndex++] = scene->mMeshes[0]->mVertices[i].z;
               // qDebug() << scene->mMeshes[0]->mVertices[i].x << ", "
               //          << scene->mMeshes[0]->mVertices[i].y << ", "
               //           << scene->mMeshes[0]->mVertices[i].z;
               //  qDebug() << "\n";
            }
            m_vertPosBuffer.create();
            m_vertPosBuffer.bind();
            m_vertPosBuffer.allocate(vertPositions, sizeof(vertPositions));
    
            const char *vertShaderSrc =
                "attribute vec3 aPosition;"
                "uniform mat4 uModelMatrix;"
                "void main()"
                "{"
                "    gl_Position = uModelMatrix * vec4(aPosition, 1.0);"
                "}";
            const char *fragShaderSrc =
                "void main()"
                "{"
                "    gl_FragColor = vec4(0.5, 0.2, 0.7, 1.0);"
                "}";
            m_program.create();
            m_program.addShaderFromSourceCode(QOpenGLShader::ShaderTypeBit::Vertex,
                vertShaderSrc);
            m_program.addShaderFromSourceCode(QOpenGLShader::ShaderTypeBit::Fragment,
                fragShaderSrc);
            m_program.link();
        }
    
        void resizeGL(int w, int h) override
        {
            glViewport(0, 0, w, h);
        }
    
        void paintGL() override
        {
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            m_modelMatrix.setToIdentity();
            m_modelMatrix.scale(0.5);
            m_program.bind();
            m_program.setUniformValue("uModelMatrix", m_modelMatrix);
            m_vertPosBuffer.bind();
            m_program.setAttributeBuffer("aPosition", GL_FLOAT, 0, 3);
            m_program.enableAttributeArray("aPosition");
            glDrawArrays(GL_TRIANGLES, 0, m_numVertices);
        }
    };
    
    int main(int argc, char *argv[])
    {
        QApplication::setAttribute(Qt::ApplicationAttribute::AA_UseDesktopOpenGL);
        QApplication app(argc, argv);
        OpenGLWidget w;
        w.show();
        return app.exec();
    }
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @8Observer8 said in How to set up Assimp for Qt6 MinGW 64-bit:

    Now I have the next error :-1: error: [Makefile:69: .\load-with-assimp-wasm-opengles2-qt6-cpp.js] Error 1

    Please post the actual error

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    8Observer88 1 Reply Last reply
    0
    • jsulmJ jsulm

      @8Observer8 said in How to set up Assimp for Qt6 MinGW 64-bit:

      Now I have the next error :-1: error: [Makefile:69: .\load-with-assimp-wasm-opengles2-qt6-cpp.js] Error 1

      Please post the actual error

      8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by
      #3

      @jsulm Qt Creator shows only this error:

      358c68f9-3934-47fe-a563-12efc7646585-image.png

      jsulmJ 1 Reply Last reply
      0
      • 8Observer88 8Observer8

        @jsulm Qt Creator shows only this error:

        358c68f9-3934-47fe-a563-12efc7646585-image.png

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @8Observer8 There should be more in the "Compile Output" tab.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        8Observer88 1 Reply Last reply
        1
        • jsulmJ jsulm

          @8Observer8 There should be more in the "Compile Output" tab.

          8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by 8Observer8
          #5

          Compiler output:

          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(AssbinLoader.cpp.o): undefined symbol: uncompress
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateInit_
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateInit2_
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflate
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflate
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflate
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateReset
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateSetDictionary
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateEnd
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateEnd
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflateInit2_
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(unzip.c.o): undefined symbol: get_crc_table
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(unzip.c.o): undefined symbol: crc32
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(Compression.cpp.o): undefined symbol: inflate
          wasm-ld: error: E:/libs/assimp-5.2.5/build/lib\libassimp.a(unzip.c.o): undefined symbol: crc32
          em++: error: 'C:/emsdk/upstream/bin\wasm-ld.exe -o .\load-with-assimp-wasm-opengl2-qt6-cpp.wasm C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledFreetype.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledLibpng.a main.obj load-with-assimp-wasm-opengl2-qt6-cpp.js_plugin_import.obj -LE:/libs/assimp-5.2.5/build/lib E:/libs/assimp-5.2.5/build/lib\libassimp.a C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/plugins/platforms/libqwasm.a C:/Qt/6.7.0/wasm_singlethread/plugins/iconengines/libqsvgicon.a C:/Qt/6.7.0/wasm_singlethread/plugins/imageformats/libqgif.a C:/Qt/6.7.0/wasm_singlethread/plugins/imageformats/libqico.a C:/Qt/6.7.0/wasm_singlethread/plugins/imageformats/libqjpeg.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledLibjpeg.a C:/Qt/6.7.0/wasm_singlethread/plugins/imageformats/libqsvg.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6Svg.a C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qstyle_fusion_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/objects-Release/Widgets_resources_4/.rcc/qrc_qmessagebox_init.cpp.o C:/Qt/6.7.0/wasm_singlethread/lib/libQt6OpenGLWidgets.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6OpenGL.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6Widgets.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6Gui.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledHarfbuzz.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledFreetype.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledLibpng.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6Core.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledZLIB.a C:/Qt/6.7.0/wasm_singlethread/lib/libQt6BundledPcre2.a -LC:\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lfetch -lembind-rtti --no-whole-archive -lGL-webgl2 -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr C:\Users\8OBSER~1\AppData\Local\Temp\tmp1971j9eilibemscripten_js_symbols.so --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=__cxa_demangle --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=malloc --export=free --export=__wasm_call_ctors --export-table -z stack-size=5242880 --initial-memory=52428800 --no-entry --max-memory=2147483648 --stack-first' failed (returned 1)
          mingw32-make: *** [Makefile:69: .\load-with-assimp-wasm-opengl2-qt6-cpp.js] Error 1
          15:05:07: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited with code 2.
          Error while building/deploying project load-with-assimp-wasm-opengl2-qt6-cpp (kit: WebAssembly Qt 6.7.0 (single-threaded))
          When executing step "Make"
          
          1 Reply Last reply
          0
          • 8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #6

            I created the same topics on Assimp discussions: https://github.com/assimp/assimp/discussions/5515 and Stack Overflow: https://stackoverflow.com/questions/78230555/how-to-set-up-assimp-for-qt6-mingw-64-bit-to-run-on-webassembly

            jsulmJ 1 Reply Last reply
            0
            • 8Observer88 8Observer8

              I created the same topics on Assimp discussions: https://github.com/assimp/assimp/discussions/5515 and Stack Overflow: https://stackoverflow.com/questions/78230555/how-to-set-up-assimp-for-qt6-mingw-64-bit-to-run-on-webassembly

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @8Observer8 Would be good to get the very first error, but it looks like a library is not found or is incompatible

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              8Observer88 1 Reply Last reply
              0
              • jsulmJ jsulm

                @8Observer8 Would be good to get the very first error, but it looks like a library is not found or is incompatible

                8Observer88 Offline
                8Observer88 Offline
                8Observer8
                wrote on last edited by
                #8

                Botje wrote the next comment on StackOverflow:

                Those are functions from zlib.

                jsulmJ 1 Reply Last reply
                0
                • 8Observer88 8Observer8

                  Botje wrote the next comment on StackOverflow:

                  Those are functions from zlib.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @8Observer8 libassimp depends on zlib, so if there is no zlip it will not work

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  8Observer88 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @8Observer8 libassimp depends on zlib, so if there is no zlip it will not work

                    8Observer88 Offline
                    8Observer88 Offline
                    8Observer8
                    wrote on last edited by 8Observer8
                    #10

                    @jsulm I built zlib with these commands:

                    cd zlib-1.3.1 && mkdir build && cd build
                    emcmake cmake ..
                    emmake make

                    libz.a (245 KB) was generated.

                    I set up it like this:

                    LIBS += -L"E:\libs\zlib-1.3.1\lib"
                    LIBS += -lz
                    

                    Now it compiles. But I think Assimp must include zlib. A size of libassimp.a is 89.3 MB.

                    I have this error now:

                    756b5dc3-bae2-4fb6-b6a6-9ef1361fc702-image.png

                    I had a problem with loading models from Qt Resources with Assimp: Loading a 3D model from Qt Resources. Assimp Error: No suitable reader found for the file format of file I decided do not use Qt Resources to solve that problem. But now I don't know how to solve it for WASM.

                    1 Reply Last reply
                    0
                    • 8Observer88 Offline
                      8Observer88 Offline
                      8Observer8
                      wrote on last edited by
                      #11

                      Botje wrote the next comment on Stack Overflow:

                      libassimp.a does not contain zlib. If you inspect the makefile generated by cmake you will see it just collects all the object files and does not add libz in any way. That is reserved for the final step where your application links to libassimp.a, because other dependencies might also need zlib and if each brings its own copy you get conflicts.

                      1 Reply Last reply
                      0
                      • 8Observer88 8Observer8 has marked this topic as solved on

                      • Login

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