Build QT 6.3 using system libraries (zlib, sqlite, etc.)
-
Hello,
I am trying to build QT 6.3 for webassembly using shared libraries that I compiled separately using emscripten (zlib.so, libsqlite3.so, libjpeg.so).
Here is the configuration command that I am using to configure QT:
./configure -xplatform wasm-emscripten -opensource -confirm-license -release -static -nomake tests -nomake examples -qt-host-path /usr/local/Qt6 -prefix $INSTALL_PATH -feature-thread -system-zlib -system-sqlite -system-libjpeg
This leads to an error during configuration indicating that zlib was not found :
CMake Error at qtbase/cmake/QtBuildInformation.cmake:400 (message): Feature "system_zlib": Forcing to "ON" breaks its condition: WrapZLIB_FOUND Condition values dump: WrapZLIB_FOUND = "FALSE" Call Stack (most recent call first): qtbase/cmake/QtFeature.cmake:281 (qt_configure_add_report_error) qtbase/cmake/QtFeature.cmake:403 (qt_feature_check_and_save_internal_value) qtbase/cmake/QtFeature.cmake:606 (qt_evaluate_feature) qtbase/cmake/QtBaseGlobalTargets.cmake:108 (qt_feature_module_end) qtbase/CMakeLists.txt:125 (include)
I tried to set CMAKE_PREFIX_PATH as indicated in QT doc to specify the folder where zlib was installed but it does not seems to change anything in my case :
-D CMAKE_PREFIX_PATH=$PROJECT_PATH/output/install \
I also tried to add the following directories manually but it does not work as well :
-L ZLIB_LIBRARY=$PROJECT_PATH/output/install/lib/libz.so \ -I ZLIB_INCLUDE_DIR=$PROJECT_PATH/output/install/include \
Any idea how to proceed? I am able to build using the libraries included with QT, but then I have an issue of conflicting symbols as the main project that I am trying to compile also use these libraries. thanks!
-
Webassembly don't support share library, all must static link. Where can you place your .so lib in a web environment? And the official document said sql is not supported. so ...... good luck.
-
Regarding your first point, I am trying to use Emscripten "Faux Dynamic Linking" which allows you to merge all your .so files in the last step of compiling with emcc. From what I understood of Emscripten documentation, this is the way to use multiple times the same library in a project without having to deal with duplicated symbols:
By default, when the -shared flag is used to build a shared library, Emscripten will produce an .so library that is actually just a regular .o object file (Under the hood it uses ld -r to combine objects into a single larger object). When these faux “shared libraries” are linked into your application they are effectively linked as static libraries. When building these shared libraries Emcc will ignore other shared libraries on the command line. This is to ensure that the same dynamic library is not linked multiple times in intermediate build stages, which would result in duplicate symbol errors.
For SQL, I know that it is not supported however I am able to build QT with internal sqlite3 library so it should work as well with an external lib. This is probably broken but I don't really care at this stage as I am just trying to include it to avoid having to refactor the code of the main project.