Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Qt WebAssembly Unable to Build: redefinition of '__glewCreateProgram' as different kind of symbol

    Qt for WebAssembly
    webassembly build failed qt creator
    2
    3
    450
    Loading More Posts
    • 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.
    • ConfusedKeystrokes
      ConfusedKeystrokes last edited by ConfusedKeystrokes

      Hello All!
      So I'm trying to build this project (which I originally build for Mac, works perfectly) to WebAssembly.

      OS: 10.15.6 (Catalina)
      XCode Version: 11.7

      I'm new to Qt, but I've been trying to do some digging to get this to work (been trying for a few days)

      I'm going to be updating this as I work through the problem, and I'll keep all the details of how I fixed previous problems for reference and to answer questions you might have.

      Hence, there are two sections: the "MY CURRENT PROBLEM" section with my current roadblock, and the HOW I GOT HERE (for the past stuff, look at that if you like).

      PS: If you could also just build the repo for me in web assembly and send me the export files; that be great 😂. This is turning out to be a huge headache due to my inexperience.

      ------------------------------------------------------------------------------------------
      ----------MY CURRENT PROBLEM----------

      ------------------------------------------------------------------------------------------
      I currently have two worries. The number 1 priority is that I can't build because of these errors:

      /Users/andersonaddo/emsdk/upstream/emscripten/system/include/GLES3/gl3.h:553: error: redefinition of '__glewCreateProgram' as different kind of symbol
      In file included from ../cs1230-final/ui/mainwindow.cpp:5:
      In file included from ../Qt/5.15.2/wasm_32/include/QtOpenGL/qgl.h:45:
      In file included from ../Qt/5.15.2/wasm_32/include/QtGui/qopengl.h:109:
      /Users/andersonaddo/emsdk/upstream/emscripten/system/include/GLES3/gl3.h:553:31: error: redefinition of '__glewCreateProgram' as different kind of symbol
      GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
                                    ^
      ../cs1230-final/glew-1.10.0/include/GL/glew.h:1897:38: note: expanded from macro 'glCreateProgram'
      #define glCreateProgram GLEW_GET_FUN(__glewCreateProgram)
                                           ^
      ../cs1230-final/glew-1.10.0/include/GL/glew.h:15167:40: note: previous definition is here
      GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram;
                                             ^
      fatal error: too many errors emitted, stopping now [-ferror-limit=]
      

      I've looked into this a bit, and it says here that building Qt from source might be a solution? I dunno though; I'm thinking there should be a simpler and less error-prone solution to this. Any ideas?

      Additionally, I'm getting a lot of these types of warnings:

      /Users/andersonaddo/Qt/5.15.2/wasm_32/include/QtCore/qglobal.h:1253: warning: variable templates are incompatible with C++ standards before C++14 [-Wc++98-c++11-compat]
      ../Qt/5.15.2/wasm_32/include/QtCore/qglobal.h:1253:82: warning: variable templates are incompatible with C++ standards before C++14 [-Wc++98-c++11-compat]
      template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
                                                                                       ^
      

      Is this something I should worry about?

      ------------------------------------------------------------------------------------------
      ----------HOW I GOT HERE----------
      ------------------------------------------------------------------------------------------

      I originally tried to follow these instructions to build from source (during which I had to do a few changes on the emsdk to get Qt to recognize it), and ran into a bunch of these types of errors:

      :-1: warning: ignoring file /Users/andersonaddo/Qt/5.15.2/wasm_32/lib/libqtharfbuzz.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
      

      I gave up after that route and tried to do this without building from source because I thought maybe I had done something wrong with building.

      So I used the Qt Online Installer, and the maintenance tool that came with it to redownload Qt Creator 4.13.3 and the Qt 5.15.2 WebAssembly Kit.

      At this point I do have the correct emscripten verions activated, I believe:

      Andersons-MBP:emsdk andersonaddo$ ./emsdk activate 1.39.8
      Setting the following tools as active:
         node-12.18.1-64bit
         python-3.7.4-2-64bit
         releases-upstream-9e60f34accb4627d7358223862a7e74291886ab6-64bit
      
      Next steps:
      - To conveniently access emsdk tools from the command line,
        consider adding the following directories to your PATH:
          /Users/andersonaddo/emsdk
          /Users/andersonaddo/emsdk/node/12.18.1_64bit/bin
          /Users/andersonaddo/emsdk/python/3.7.4-2_64bit/bin
          /Users/andersonaddo/emsdk/upstream/emscripten
      - This can be done for the current shell by running:
          source "/Users/andersonaddo/emsdk/emsdk_env.sh"
      - Configure emsdk in your bash profile by running:
          echo 'source "/Users/andersonaddo/emsdk/emsdk_env.sh"' >> $HOME/.bash_profile
      

      My Kit now Looks like this:
      Screen Shot 2020-12-12 at 1.39.58 PM.png
      The compilers are the automatically detected ones.

      At this point I started getting these errors (before running):

      Project WARNING: This Qt was built with Emscripten version 1.39.8. You have . The difference may cause issues.
      
      warning: "/Users/andersonaddo/emsdk/fastcomp/emscripten/emcc" is used by qmake, but "Users/andersonaddo/emsdk/fastcomp/fastcomp/bin/clang" is configured in the kit.
      Please update your kit (Qt 5.15.2 WebAssembly) or choose a mkspec for qmake that matches your target environment better.
      
      warning: "/Users/andersonaddo/emsdk/fastcomp/emscripten/em++" is used by qmake, but "Users/andersonaddo/emsdk/fastcomp/fastcomp/bin/clang" is configured in the kit.
      Please update your kit (Qt 5.15.2 WebAssembly) or choose a mkspec for qmake that matches your target environment better.
      

      And when I try to run it regardless then I get these errors:

      :-1: warning: em++: No such file or directory
      
      :-1: error: [final.js_plugin_import.o] Error 1
      

      So I decided maybe I should change the compilers to point to emsdk files that point to files with the names em++ and emcc.
      So I used these compilers (manually added)
      Screen Shot 2020-12-12 at 1.56.13 PM.png Screen Shot 2020-12-12 at 1.56.07 PM.png

      But then I get these types of errors:

      Compiler feature detection failure!
      The command "/Users/andersonaddo/emsdk/fastcomp/emscripten/em++ -print-search-dirs" terminated with exit code 1.
      shared:ERROR: no input files
      note that input files without a known suffix are ignored, make sure your input files end with one of: ('.c', '.C', '.i', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.CC', '.C++', '.ii', '.m', '.mi', '.mm', '.mii', '/dev/null', '.bc', '.o', '.obj', '.lo', '.dylib', '.so', '.a', '.ll', '.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
      
      "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" is used by qmake, but "/Users/andersonaddo/emsdk/fastcomp/emscripten/emcc" is configured in the kit.
      Please update your kit (Qt 5.15.2 WebAssembly) or choose a mkspec for qmake that matches your target environment better.
      

      And at the end of the day, I get still end up right where I started, with these errors:

      :-1: warning: ignoring file /Users/andersonaddo/Qt/5.15.2/wasm_32/plugins/imageformats/libqico.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
      

      Which understandably, cause Undefined symbol errors and linker errors.

      So I looked into the "ignoring file" error more, but all I found is this. Apparently they say it might be a Xcode bug or something? I didn't quite understand their fix though - they say it can be helpful to force the target macos version. I tried doing it in this portion of my projects .pro file:

      macx {
          QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.14 <------changed from 10.7
          QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64
          CONFIG += c++11
      }
      

      but no luck.

      Along the way, during this process, these files were added to my project:
      final.js_plugin_import.cpp
      final_plugin_import.cpp
      They both look like:

      // This file is autogenerated by qmake. It imports static plugin classes for
      // static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables.
      #include <QtPlugin>
      Q_IMPORT_PLUGIN(QWasmIntegrationPlugin)
      Q_IMPORT_PLUGIN(QGifPlugin)
      Q_IMPORT_PLUGIN(QICNSPlugin)
      Q_IMPORT_PLUGIN(QICOPlugin)
      Q_IMPORT_PLUGIN(QJpegPlugin)
      Q_IMPORT_PLUGIN(QTgaPlugin)
      Q_IMPORT_PLUGIN(QTiffPlugin)
      Q_IMPORT_PLUGIN(QWbmpPlugin)
      Q_IMPORT_PLUGIN(QWebpPlugin)
      

      So I decided to look at things and tinker a bit more. I found out that I had made a mistake with my copy of the .emscripten file (things were pointing to the wrong places), so I corrected it to look like:

      import os
      emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\', '/')
      NODE_JS = '/Users/andersonaddo/emsdk/node/12.18.1_64bit/bin/node'
      PYTHON = '/Users/andersonaddo/emsdk/python/3.7.4-2_64bit/bin/python3'
      LLVM_ROOT = '/Users/andersonaddo/emsdk/upstream/bin'
      BINARYEN_ROOT = '/Users/andersonaddo/emsdk/upstream'
      EMSCRIPTEN_ROOT = '/Users/andersonaddo/emsdk/upstream/emscripten'
      TEMP_DIR = '/Users/andersonaddo/emsdk/tmp'
      COMPILER_ENGINE = NODE_JS
      JS_ENGINES = [NODE_JS]
      EMCC_DEBUG=1
      

      And I also changed my manually added compilers to:
      Screen Shot 2020-12-12 at 11.56.25 PM.png
      Screen Shot 2020-12-12 at 11.56.21 PM.png

      I then tried to build, and it seemed like it was working! But then... [look at WHERE I AM section now]

      1 Reply Last reply Reply Quote 0
      • lorn.potter
        lorn.potter last edited by

        What app are you trying to build? Are you including GL/glew.h yourself?

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

        ConfusedKeystrokes 1 Reply Last reply Reply Quote 0
        • ConfusedKeystrokes
          ConfusedKeystrokes @lorn.potter last edited by ConfusedKeystrokes

          @lorn-potter Thanks for getting back to me!

          I'm trying to build this project:
          https://github.com/herewegoblueno/cs1230-final
          Just to provide context, this works well when built for Mac.

          And yes I am importing GL/glew.h myself.

          Also by the way I've also noticed that the compilers don't recognize the standard libraries like <vector>, <map>, etc (or maybe that's just the static checker? not sure if those will result in compile time errors since I can't build due to glew anyways)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post