-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using the qt mingw compiler on windows, graphs are not generated successfully #257
Comments
@tsukione Can you try adding the following at the top of your add_compile_flags:
- --target=x86_64-w64-mingw32 It's possible that your |
Tried it and got some new errors.
How can I run clang-uml with LLVM/Clang if I compile with the mingw compiler that comes with Qt on Windows? Do I need to use the LLVM compiler to compile Qt and my project completely again? |
@tsukione No you don't need to compile your project with LLVM to run Can you describe how can I reproduce this error, including which Qt version I need to install? |
just include I've looked into it, and it does look like there are quite a few macro definitions missing, leading to the wrong branch of code. But I don't know how to get cmake to export all the definitions. |
@tsukione I've finally managed to reproduce your problem and have found a possible solution to it. The core of the issue is that Mingw GCC contains headers with Intel SIMD instructions which are incompatible with Clang - fortunately for the sake of just running I've created a smallest possible project in QtCreator, included the add_compile_flags:
- --target=x86_64-w64-mingw32
- -D__IPHLPAPI_H__=1 to my Here is my setup: PS C:\Users\bkryz\Documents\clang-uml-test> ls
Directory: C:\Users\bkryz\Documents\clang-uml-test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/11/2024 6:31 PM build
d----- 4/11/2024 6:40 PM docs
-a---- 4/11/2024 7:11 PM 349 .clang-uml
-a---- 4/11/2024 6:34 PM 741 CMakeLists.txt
-a---- 4/11/2024 6:31 PM 15926 CMakeLists.txt.user
-a---- 4/11/2024 6:53 PM 221 main.cpp
PS C:\Users\bkryz\Documents\clang-uml-test> cat .\main.cpp
#include <QCoreApplication>
#include <iphlpapi.h>
namespace my_app {
struct A {};
struct B : public A {};
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
} PS C:\Users\bkryz\Documents\clang-uml-test> cat .\CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(clang-uml-test LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
add_executable(clang-uml-test
main.cpp
)
target_link_libraries(clang-uml-test Qt${QT_VERSION_MAJOR}::Core)
include(GNUInstallDirs)
install(TARGETS clang-uml-test
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) PS C:\Users\bkryz\Documents\clang-uml-test> cat .\build\Desktop_Qt_6_7_0_MinGW_64_bit-Debug\compile_commands.json
[
{
"directory": "C:/Users/bkryz/Documents/clang-uml-test/build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug",
"command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Users/bkryz/Documents/clang-uml-test/build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug/clang-uml-test_autogen/include -isystem C:/Qt/6.7.0/mingw_64/include/QtCore -isystem C:/Qt/6.7.0/mingw_64/include -isystem C:/Qt/6.7.0/mingw_64/mkspecs/win32-g++ -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -isystem C:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include -DQT_QML_DEBUG -g -std=gnu++17 -fdiagnostics-color=always -o CMakeFiles\\clang-uml-test.dir\\clang-uml-test_autogen\\mocs_compilation.cpp.obj -c C:\\Users\\bkryz\\Documents\\clang-uml-test\\build\\Desktop_Qt_6_7_0_MinGW_64_bit-Debug\\clang-uml-test_autogen\\mocs_compilation.cpp",
"file": "C:\\Users\\bkryz\\Documents\\clang-uml-test\\build\\Desktop_Qt_6_7_0_MinGW_64_bit-Debug\\clang-uml-test_autogen\\mocs_compilation.cpp",
"output": "CMakeFiles\\clang-uml-test.dir\\clang-uml-test_autogen\\mocs_compilation.cpp.obj"
},
{
"directory": "C:/Users/bkryz/Documents/clang-uml-test/build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug",
"command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Users/bkryz/Documents/clang-uml-test/build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug/clang-uml-test_autogen/include -isystem C:/Qt/6.7.0/mingw_64/include/QtCore -isystem C:/Qt/6.7.0/mingw_64/include -isystem C:/Qt/6.7.0/mingw_64/mkspecs/win32-g++ -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -isystem C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -isystem C:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include -DQT_QML_DEBUG -g -std=gnu++17 -fdiagnostics-color=always -o CMakeFiles\\clang-uml-test.dir\\main.cpp.obj -c C:\\Users\\bkryz\\Documents\\clang-uml-test\\main.cpp",
"file": "C:\\Users\\bkryz\\Documents\\clang-uml-test\\main.cpp",
"output": "CMakeFiles\\clang-uml-test.dir\\main.cpp.obj"
}
] PS C:\Users\bkryz\Documents\clang-uml-test> cat .clang-uml
compilation_database_dir: build/Desktop_Qt_6_7_0_MinGW_64_bit-Debug
output_directory: docs/diagrams
add_compile_flags:
- --target=x86_64-w64-mingw32
- -D__IPHLPAPI_H__=1
diagrams:
my_app_class_diagram:
type: class
glob:
- "*.cpp"
using_namespace:
- my_app
include:
namespaces:
- my_app PS C:\Users\bkryz\Documents\clang-uml-test> & 'C:\Program Files\clang-uml\bin\clang-uml.exe' --version
clang-uml 0.5.1
Copyright (C) 2021-2024 Bartek Kryza <bkryza@gmail.com>
Windows, 32-bit
Built against LLVM/Clang libraries version: 17.0.6
Using LLVM/Clang libraries version: clang version 17.0.6 (https://github.com/llvm/llvm-project.git 6009708b4367171ccdbf4b5905cb6a803753fe18)
PS C:\Users\bkryz\Documents\clang-uml-test> & 'C:\Program Files\clang-uml\bin\clang-uml.exe'
fatal: not a git repository (or any of the parent directories): .git
[info] [tid 11960] [C:\clang-uml-llvm17-tmp\clang-uml\src\cli\cli_handler.cc:305] Loaded clang-uml config from .clang-uml
[info] [tid 11960] [C:\clang-uml-llvm17-tmp\clang-uml\src\cli\cli_handler.cc:333] Loading compilation database from C:\Users\bkryz\Documents\clang-uml-test\build\Desktop_Qt_6_7_0_MinGW_64_bit-Debug directory
[info] [tid 7516] [C:\clang-uml-llvm17-tmp\clang-uml\src\common\generators\generators.h:368] Generating diagram my_app_class_diagram
[info] [tid 7516] [C:\clang-uml-llvm17-tmp\clang-uml\src\common\generators\generators.cc:112] Written my_app_class_diagram diagram to C:\Users\bkryz\Documents\clang-uml-test\docs\diagrams\my_app_class_diagram.puml PS C:\Users\bkryz\Documents\clang-uml-test> cat .\docs\diagrams\my_app_class_diagram.puml
@startuml
class "A" as C_0000693866551648885556
class C_0000693866551648885556 {
__
}
class "B" as C_0000693866414209932029
class C_0000693866414209932029 {
__
}
C_0000693866551648885556 <|-- C_0000693866414209932029
'Generated with clang-uml, version 0.5.1
'LLVM version clang version 17.0.6 (https://github.com/llvm/llvm-project.git 6009708b4367171ccdbf4b5905cb6a803753fe18)
@enduml If you'll have problems with any other Mingw internal header files not being parsed by Clang properly, just try to defined their header guard in the |
Thank you very much for your very detailed analysis and answers to my questions. Just like that, it also means that the API provided by these header files cannot be used. Maybe I have to isolate the API interface on the code to use clang-uml properly. |
When the clang-uml.exe command is executed, the path of the mingw header file is found, but the following error message is displayed.
The text was updated successfully, but these errors were encountered: