Embedding ROOT in QT on windows

The Debug mode is tricky when it comes to external dependencies. Try the RelWithDebInfo mode. The reason is that ROOT built in Debug mode uses the Release runtime libraries, to prevent forcing all external dependencies to be build in Debug mode (on Windows one cannot mix debug and release builds)

It works for me in “Release” mode!
Also -DQt5_DIR is not necessary when PATH configured correctly.
I will update readme and submit PR

1 Like

You are very efficient, that is amazing!
I will try tonight to compile again with the new modification of the master and I will let you know if it is ok for me.
Thanks a lot.
Thomas

Make sure you build in Release mode with the Release version of the Qt libraries

Ok then, I do not know what happens with my computer. I have recompiled everything with the new master and Qt5.15.2 in release mod. The same crash still happens: the execution starts and collapses with no error message…

I join the result of cmake below. Some libraries are missing but nothing that seems to be important. I will try on a clean setup tomorrow, just in case I would have environment variables leading to some problems.

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.29.2.windows.2")
-- Looking for Python
-- Could NOT find Python3 (missing: Python3_EXECUTABLE Python3_NumPy_INCLUDE_DIRS Interpreter NumPy) (found version "3.8.1")
    Reason given by package:
        Interpreter: Wrong architecture for the interpreter "C:/Program Files/Python38/python.exe"

-- Could NOT find Python2 (missing: Python2_EXECUTABLE Python2_NumPy_INCLUDE_DIRS Interpreter NumPy) (found version "2.7.17")
    Reason given by package:
        Interpreter: Wrong major version for the interpreter "C:/Program Files/Python38/python.exe"

CMake Warning at cmake/modules/SearchRootCoreDeps.cmake:222 (message):
  No supported Python 2 or 3 development packages were found; PyROOT will not
  be built.
Call Stack (most recent call first):
  CMakeLists.txt:129 (include)


-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Performing Test GLIBCXX_USE_CXX11_ABI
-- Performing Test GLIBCXX_USE_CXX11_ABI - Failed
-- ROOT Platform: win32
-- ROOT Compiler: MSVC 19.28.29913.0
-- ROOT Processor: AMD64
-- ROOT Architecture: win32
-- Build Type: '' (flags = '')
-- Compiler Flags: -nologo -ID:/LIB_PROG/root-master/build/win -FIw32pragma.h -FIsehmap.h -Zc:__cplusplus -MD -GR -EHsc- -W3 -wd4141 -wd4291 -wd4244 -wd4049 -D_WIN32  -D_XKEYCHECK_H -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS
-- ROOT default compression algorithm: zlib
-- PyROOT will be built for version
-- Looking for ZLib
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.5")
-- Zlib not found. Switching on builtin_zlib option
-- Looking for Freetype
-- Could NOT find Freetype (missing: FREETYPE_LIBRARY) (found version "2.4.4")
-- FreeType not found. Switching on builtin_freetype option
-- Building freetype version 2.6.1 included in ROOT itself
-- Looking for PCRE
-- Could NOT find PCRE (missing: PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY)
-- PCRE not found. Switching on builtin_pcre option
-- Looking for LZMA
-- Could NOT find LibLZMA (missing: LIBLZMA_LIBRARY LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET) (found version "5.0.2")
-- LZMA not found. Switching on builtin_lzma option
-- Building LZMA version 5.2.4 included in ROOT itself
-- Looking for xxHash
-- Could NOT find xxHash (missing: xxHash_LIBRARY xxHash_INCLUDE_DIR)
-- xxHash not found. Switching on builtin_xxhash option
-- Looking for ZSTD
-- Could NOT find ZSTD (missing: ZSTD_LIBRARIES ZSTD_INCLUDE_DIR ZSTD_VERSION)
-- ZSTD not found. Switching on builtin_zstd option
-- Performing Test C_FLAG_MP
-- Performing Test C_FLAG_MP - Success
-- Performing Test CXX_FLAG_MP
-- Performing Test CXX_FLAG_MP - Success
-- Performing Test C_FLAG_D_UNICODE
-- Performing Test C_FLAG_D_UNICODE - Success
-- Performing Test CXX_FLAG_D_UNICODE
-- Performing Test CXX_FLAG_D_UNICODE - Success
-- Performing Test C_FLAG_DUNICODE
-- Performing Test C_FLAG_DUNICODE - Success
-- Performing Test CXX_FLAG_DUNICODE
-- Performing Test CXX_FLAG_DUNICODE - Success
-- Looking for LZ4
-- Could NOT find LZ4 (missing: LZ4_LIBRARY LZ4_INCLUDE_DIR)
-- LZ4 not found. Switching on builtin_lz4 option
-- Performing Test GIF_GifFileType_UserData
-- Performing Test GIF_GifFileType_UserData - Success
-- Could NOT find GIF (missing: GIF_LIBRARY) (found version "4")
-- Could NOT find TIFF (missing: TIFF_LIBRARY) (found version "3.9.5")
-- Could NOT find PNG (missing: PNG_LIBRARY) (found version "1.5.2")
-- Could NOT find JPEG (missing: JPEG_LIBRARY) (found version "80")
-- Looking for AfterImage
-- Could NOT find AfterImage (missing: AFTERIMAGE_INCLUDE_DIR AFTERIMAGE_LIBRARIES)
-- AfterImage not found. Switching on builtin_afterimage option
-- Looking for GSL
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find GSL: Found unsuitable version "", but required is at least "1.10" (found GSL_INCLUDE_DIR-NOTFOUND)
-- GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation
--                Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'
--                For the time being switching OFF 'mathmore' option
-- Looking for OpenGL
-- Found OpenGL: opengl32
-- Looking for GLEW
-- Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
-- GLEW not found. Switching on builtin_glew option
-- Looking for gl2ps
-- Could NOT find gl2ps (missing: GL2PS_LIBRARY GL2PS_INCLUDE_DIR)
-- gl2ps not found. Switching on builtin_gl2ps option
-- Looking for LibXml2
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY) (found version "2.7.8")
-- LibXml2 not found. Switching off xml option
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found version "1.0.0d")
-- Switching OFF 'ssl' option.
-- Looking for MySQL
-- Could NOT find MySQL (missing: MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
-- MySQL not found. Switching off mysql option
-- Looking for Oracle
-- Oracle not found.
-- Oracle: You can specify includes: -DORACLE_PATH_INCLUDES=/usr/include/oracle/10.2.0.3/client
--    currently found includes:
-- Oracle: You can specify libs: -DORACLE_PATH_LIB=/usr/lib/oracle/10.2.0.3/client/lib
--    currently found libs: ORACLE_LIBRARY_OCCI-NOTFOUND;ORACLE_LIBRARY_CLNTSH-NOTFOUND;ORACLE_LIBRARY_LNNZ-NOTFOUND
-- Oracle not found. Switching off oracle option
-- Looking for PostgreSQL
-- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY)
-- PostgreSQL not found. Switching off pgsql option
-- Looking for SQLite
-- Could NOT find Sqlite (missing: SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)
-- SQLite not found. Switching off sqlite option
-- Looking for Pythia6
-- Pythia6 not found. Switching off pythia6 option
-- Looking for Pythia8
-- Could NOT find Pythia8 (missing: PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARY)
-- Pythia8 not found. Switching off pythia8 option
-- Looking for FFTW3
-- FFTW3 not found. Set [environment] variable FFTW_DIR to point to your FFTW3 installation
--                  Alternatively, you can also enable the option 'builtin_fftw3' to build FFTW3 internally'
--                  For the time being switching OFF 'fftw3' option
-- Looking for CFITSIO
-- Could NOT find CFITSIO (missing: CFITSIO_LIBRARY CFITSIO_INCLUDE_DIR)
-- CFITSIO not found. You can enable the option 'builtin_cfitsio' to build the library internally'
--                    For the time being switching off 'fitsio' option
-- Could NOT find GFAL (missing: GFAL_INCLUDE_DIR SRM_IFCE_INCLUDE_DIR GFAL_LIBRARY)
-- GFAL library not found. Set variable GFAL_DIR to point to your gfal installation
                      and the variable SRM_IFCE_DIR to the srm_ifce installation
-- For the time being switching OFF 'gfal' option
-- Could NOT find FTGL (missing: FTGL_INCLUDE_DIR FTGL_LIBRARY)
-- ftgl library not found. Set variable FTGL_ROOT_DIR to point to your installation
-- For the time being switching ON 'builtin_ftgl' option
-- Cannot select cudnn without selecting cuda or tmva-gpu. Option is ignored
-- Performing Test ROOT_HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test ROOT_HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Building LLVM in 'Release' mode.
-- The ASM compiler identification is MSVC
-- Found assembler: D:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x86/cl.exe
-- Could NOT find Z3: Found unsuitable version "0.0.0", but required is at least "4.7.1" (found Z3_LIBRARIES-NOTFOUND)
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
-- Native target architecture is X86
-- Threads disabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- Could NOT find Python module pygments
-- Could NOT find Python module pygments.lexers.c_cpp
-- Could NOT find Python module yaml
-- LLVM host triple: i686-pc-windows-msvc
-- LLVM default target triple: i686-pc-windows-msvc
-- Found PythonInterp: C:/Program Files/Python38/python.exe (found version "3.8.1")
-- Constructing LLVMBuild project information
-- LLVMHello ignored -- Loadable modules not supported on this platform.
-- Targeting X86
-- Targeting NVPTX
-- Clang version: 9.0.1
-- PrintFunctionNames ignored -- Loadable modules not supported on this platform.
-- AnnotateFunctions ignored -- Loadable modules not supported on this platform.
-- BugpointPasses ignored -- Loadable modules not supported on this platform.
-- Cling version (from VERSION file): ROOT_0.9~dev
-- Performing Test __result
-- Performing Test __result - Failed
-- Performing Test CXX_HAS_fno_rtti
-- Performing Test CXX_HAS_fno_rtti - Failed
-- Performing Test C_HAS_Wno_strict_overflow
-- Performing Test C_HAS_Wno_strict_overflow - Failed
-- Performing Test C_HAS_Wno_maybe_uninitialized
-- Performing Test C_HAS_Wno_maybe_uninitialized - Failed
-- Performing Test C_HAS_Wno_parentheses_equality
-- Performing Test C_HAS_Wno_parentheses_equality - Failed
-- Looking for m
-- Looking for m - not found
-- Performing Test found_setresuid
-- Performing Test found_setresuid - Failed
-- Performing Test found_stdstringview
-- Performing Test found_stdstringview - Failed
-- Performing Test found_stdexpstringview
-- Performing Test found_stdexpstringview - Failed
-- Performing Test found_stdapply
-- Performing Test found_stdapply - Failed
-- Performing Test found_stdinvoke
-- Performing Test found_stdinvoke - Success
-- Performing Test found_stdindexsequence
-- Performing Test found_stdindexsequence - Success
-- Performing Test found_attribute_always_inline
-- Performing Test found_attribute_always_inline - Failed
-- Performing Test has_found_attribute_noinline
-- Performing Test has_found_attribute_noinline - Failed
-- ROOT Configuration

System          Windows-10.0.19041
Processor       6 core 2592 MHz GenuineIntel Unknown P6 family (AMD64)
Build type
Install path    C:/Program Files (x86)/ROOT
Compiler        MSVC 19.28.29913.0
Compiler flags:
C               -nologo -ID:/LIB_PROG/root-master/build/win -FIw32pragma.h -FIsehmap.h -MD -EHsc- -W3 -D_WIN32  -DNOMINMAX   -DNDEBUG
C++             -nologo -ID:/LIB_PROG/root-master/build/win -FIw32pragma.h -FIsehmap.h -Zc:__cplusplus -MD -GR -EHsc- -W3 -wd4141 -wd4291 -wd4244 -wd4049 -D_WIN32  -D_XKEYCHECK_H -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS   -DNDEBUG
Linker flags:
Executable      /machine:X86
Module          /machine:X86 -ignore:4049,4206,4217,4221 -incremental:no
Shared          /machine:X86 -ignore:4049,4206,4217,4221 -incremental:no

-- Enabled support for:  asimage builtin_afterimage builtin_clang builtin_cling builtin_freetype builtin_ftgl builtin_gl2ps builtin_glew builtin_llvm builtin_lz4 builtin_lzma builtin_nlohmannjson builtin_openui5 builtin_pcre builtin_xxhash builtin_zlib builtin_zstd clad exceptions gdml http mlp opengl qt5web webgui root7 shared spectrum
-- Configuring done
-- Generating done
-- Build files have been written to: D:/LIB_PROG/root6

Hello,
I have done all the compilation process on another fresh windows setup. Unfortunately, I still have the same problem.
My attempt to isolate the crash made me observe two things:

  1. In RCanvasWidget and TCanvasWidget, if I replace fCanvas->Show(where); by fCanvas->Show();, the code does not crash. Of course it is not a solution because the ROOT object is not anymore executed inside the QWidget.
  2. For RGeomViewerObject, the two following code line bring to the crash:
   fGeomViewer = std::make_shared<ROOT::Experimental::REveGeomViewer>();
(...)
   fGeomViewer->Show(where); //even by removing "where"

I do not really know how the Show() method works but is it possible that the size or location of the ROOT object is leading somehow to a problem inside the QWidget?

Hi Thomas,

Strange that you still have errors.
I create special branch where I add some debug output.
Please build it in Release mode and then qt5web as described in compile instructions

Then try to run application with

Release\qt5web.exe > log.txt

In log file one should see output like this:

Assiign parent widget 0A78A0E8
Use parent widget 0A78A0E8
Assiign parent widget 11378DC0
Use parent widget 11378DC0
Assiign parent widget 114F5B10
Use parent widget 114F5B10

There is pointer → string → pointer conversion in qt5 web-based display in ROOT and maybe it fails for you. Please verify this first.

Regards,
Sergey

Hello Sergey,
Thanks for your attention to my problem.
I have done what you suggested. Nothing has been written in the log file but in the terminal, I got:
Fatal in <TROOT::InitInterpreter>: cannot load library. A dynamic link library (dll) initialization routine failed.
I have copied all the DLLS from the bin folder next to my executable (QT + ROOT).
I will check what is InitInterpreter.
Best,
Thomas

Hi,

In shell where you start application, you should call:

call c:\soft\root\bin\thisroot.bat
set PATH=%PATH%;C:\Qt\5.12.6\msvc2017\bin

It should be enough to set all necessary paths.

Regards,
Sergey

That is what I do, but I wanted to be sure it was not a library problem so I copied the DLL. I tried again by re-setting the environment paths with no success

I only can again ping Bertrand @bellenot.
I hope he have idea that could be wrong in TROOT::InitInterpreter

Please dont move dlls around. This might only lead to more problems and possible conflicts. As @linev said, calling c:\soft\root\bin\thisroot.bat is enough (and mandatory)

Do you have by chance other ROOT installations on your system?
Can you check that in PATH variable no any older ROOT libraries are accessible?

And about Fatal in <TROOT::InitInterpreter>: cannot load library. A dynamic link library (dll) initialization routine failed, as the error says, one DLLs failed to load, but the system doesn’t tell which one

BTW, can you run ROOT from the command prompt, and run some tutorials, just to make sure ROOT itself is correctly built?

Yes, root is perfectly loading and the examples work as well
image
I do not understand why I do not succeed with qt5web.
And it seems it s the correct ROOT version that is found
image

I finally found what the problems ARE but it is a bit strange:

  1. As you both suggested, having the DLL of ROOT in the folder of the exe leads to a crash. But I do not understand why. Someone who would like to deploy an application with root inside cannot link it dynamically by this way?
  2. QT needs to be able to access the resources file for WebEngine which have to be provided (solved by adding in the path)
  3. QT also needs to access the WebEngine locales (solved by adding in the path)

Thanks a lot both of you for your help.
Best,
Thomas

1 Like

As I said, it’s not sufficient to have the ROOT DLLs in the PATH. The ROOTSYS environment variable must be set, and several directories relative to ROOTSYS are needed by ROOT itself (fonts, configuration files, plugins, …)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.