juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.
https://juce.com
Other
6.55k stars 1.73k forks source link

[Bug]: Fail to build 8.0.0 juceaide on msys2 clang64 #1409

Closed ExerciseBook closed 2 months ago

ExerciseBook commented 2 months ago

Detailed steps on how to reproduce the bug

  1. Install a new MSYS2 Clang64 image

image

  1. Clone a new JUCE

image

  1. Build juceaide
    mkdir cmake-build
    cd cmake-build
    cmake -GNinja -DJUCE_BUILD_HELPER_TOOLS=ON ..

image

ninja

image

and I get the error

What is the expected behaviour?

Success to build juceaide

Operating systems

Windows

What versions of the operating systems?

see above

Architectures

x86_64, 64-bit

Stacktrace

No response

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

ExerciseBook commented 2 months ago

I attempt to fix this problem by this

diff --git a/extras/Build/juceaide/CMakeLists.txt b/extras/Build/juceaide/CMakeLists.txt
index a75fa1f01..9c41854e3 100644
--- a/extras/Build/juceaide/CMakeLists.txt
+++ b/extras/Build/juceaide/CMakeLists.txt
@@ -47,13 +47,36 @@ if(JUCE_BUILD_HELPER_TOOLS)
         # This is a temporary workaround to allow builds to complete on Xcode 15.
         # Add -Wl,-ld_classic to the OTHER_LDFLAGS build setting if you need to
         # deploy to older versions of macOS.
-        JUCE_SILENCE_XCODE_15_LINKER_WARNING=1)
-
-    target_link_libraries(juceaide PRIVATE
-        juce::juce_build_tools
-        juce::juce_recommended_config_flags
-        juce::juce_recommended_lto_flags
-        juce::juce_recommended_warning_flags)
+        JUCE_SILENCE_XCODE_15_LINKER_WARNING=1
+    )
+
+    if (WIN32 AND MINGW)
+        target_compile_definitions(juceaide PUBLIC
+            JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES=ON
+            NTDDI_VERSION=0x0A000002
+        )
+
+        target_link_libraries(juceaide PRIVATE
+                juce::juce_build_tools
+                juce::juce_recommended_config_flags
+                juce::juce_recommended_lto_flags
+                juce::juce_recommended_warning_flags
+
+                Dwrite
+                D2d1
+                DXGI
+                D3D11
+                DComp
+                dxguid
+        )
+    else()
+        target_link_libraries(juceaide PRIVATE
+                juce::juce_build_tools
+                juce::juce_recommended_config_flags
+                juce::juce_recommended_lto_flags
+                juce::juce_recommended_warning_flags
+        )
+    endif()

     set_target_properties(juceaide PROPERTIES
         MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp
index 9d3e10d0b..d4e629f33 100644
--- a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp
+++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp
@@ -1615,13 +1615,13 @@ void Direct2DGraphicsContext::drawGlyphs (Span<const uint16_t> glyphNumbers,

         ComSmartPtr<IDWriteColorGlyphRunEnumerator1> enumerator;

-        constexpr auto formats = DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE
+        constexpr auto formats = (DWRITE_GLYPH_IMAGE_FORMATS) (DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE
                                | DWRITE_GLYPH_IMAGE_FORMATS_CFF
                                | DWRITE_GLYPH_IMAGE_FORMATS_COLR
                                | DWRITE_GLYPH_IMAGE_FORMATS_PNG
                                | DWRITE_GLYPH_IMAGE_FORMATS_JPEG
                                | DWRITE_GLYPH_IMAGE_FORMATS_TIFF
-                               | DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8;
+                               | DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8);

         if (const auto hr = factory->TranslateColorGlyphRun (baselineOrigin,
                                                              &directWriteGlyphRun,
diff --git a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp
index f298a33fa..2a1596365 100644
--- a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp
+++ b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp
@@ -53,7 +53,7 @@ struct Direct2DDeviceContext
         D2D1_HWND_RENDER_TARGET_PROPERTIES hwndRenderTargetProps{};
         hwndRenderTargetProps.hwnd = hwnd;
         hwndRenderTargetProps.pixelSize = size;
-        hwndRenderTargetProps.presentOptions = D2D1_PRESENT_OPTIONS_IMMEDIATELY | D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS;
+        hwndRenderTargetProps.presentOptions = (D2D1_PRESENT_OPTIONS) (D2D1_PRESENT_OPTIONS_IMMEDIATELY | D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS);
         return directX->getD2DFactory()->CreateHwndRenderTarget (&renderTargetProps,
                                                                  &hwndRenderTargetProps,
                                                                  hwndRenderTarget.resetAndGetPointerAddress());

but I also failed to build

image

reuk commented 2 months ago

JUCE does not support the msys2 environment. To build JUCE on Windows, please use native Clang or MSVC, with the headers and libraries from the official Windows SDK.