Cesium for Unreal fails to compile in UE5.7 with Shipping configuation (blocks packaging)

Hey Cesium team, I don’t know if this also impacts blueprints only projects cause I didn’t try but in my c++ project I couldn’t Package the project or compile in shipping configuration as I got these errors:

Severity	Code	Description	Project	File	Line	Suppression State	Details Error	C3878	syntax error: unexpected token ‘)’ following ‘statement-seq’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘)’ following ‘statement’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘)’ following ‘selection-statement’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘)’ following ‘expression-statement’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘)’ following ‘expression-statement’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C3878	syntax error: unexpected token ‘)’ following ‘expression-statement’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358		 Error	C3878	syntax error: unexpected token ‘)’ following ‘compound-statement’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘(’ following ‘expression’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C3878	syntax error: unexpected token ‘(’ following ‘expression’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C3878	syntax error: unexpected token ‘(’ following ‘expression’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358		 Error	C2143	syntax error: missing ‘(’ before ‘)’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\Variants\MovieSceneNumericVariant.h	311		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘}’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘expression’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘expression’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘expression’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘;’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘;’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C2760	syntax error: ‘)’ was unexpected here; expected ‘;’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358		 Error	C2059	syntax error: ‘)’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\Variants\MovieSceneNumericVariant.h	311		 Error	C2059	syntax error: ‘)’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\Variants\MovieSceneNumericVariant.h	313		 Error	C2059	syntax error: ‘)’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	12		 Error	C2059	syntax error: ‘(’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	12		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\Variants\MovieSceneNumericVariant.h	311		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	12		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	58		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	65		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C4003	not enough arguments for function-like macro invocation ‘max’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358		 Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	12		 Error	C2065	‘OffsetPtr’: undeclared identifier	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C2589	‘(’: illegal token on right side of ‘’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\Variants\MovieSceneNumericVariant.h	311		 Error	C2589	‘(’: illegal token on right side of ‘’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	12		 Error	C2589	‘(’: illegal token on right side of ‘’	SimplexUnreal	D:\Epic\UE_5.7\Engine\Source\Runtime\MovieScene\Public\EntitySystem\RelativePtr.h	57		 Error	C2589	‘(’: illegal token on right side of ‘’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	357		 Error	C2589	‘(’: illegal token on right side of ‘::’	SimplexUnreal	D:\ArchVizExplorer\Plugins\CesiumForUnreal\Source\ThirdParty\include\CesiumGltf\AccessorUtility.h	358

With the help of copilot we zeroed in on some missing includes in the AccessorUtility.h header and a change that needed to be made to the CesiumRuntime.Build.cs file as following:

#pragma once

#include <CesiumGltf/AccessorView.h>
#include <CesiumGltf/MeshPrimitive.h>

#include <glm/common.hpp>

#include <array>
#include <variant>
#include <vector>
#include <optional>   // ADD: needed for std::optional
#include <limits>     // ADD: needed for std::numeric_limits

namespace CesiumGltf {
// ... unchanged code ...

  template <typename T>
  std::optional<glm::dvec2>
  operator()(const AccessorView<CesiumGltf::AccessorTypes::VEC2<T>>& value) {
    if (index < 0 || index >= value.size()) {
      return std::nullopt;
    }

    double u = static_cast<double>(value[index].value[0]);
    double v = static_cast<double>(value[index].value[1]);

    // Normalize into [0,1]
    u /= (std::numeric_limits<T>::max)();  // CHANGED: parenthesized to avoid Windows max macro
    v /= (std::numeric_limits<T>::max)();  // CHANGED: parenthesized to avoid Windows max macro

    return glm::dvec2(u, v);
  }

// ... unchanged code ...
} // namespace CesiumGltf

And in the build.cs:

using UnrealBuildTool;

public class CesiumRuntime : ModuleRules
{
    public CesiumRuntime(ReadOnlyTargetRules Target) : base(Target)
    {
        // ... existing config ...

        PublicDefinitions.Add("NOMINMAX=1"); // ADD: prevent Windows min/max macros

        // ... existing config ...
    }
}

After making these changes packaging seemed to have worked correctly.

Cheers

Hi @Amir-BK, welcome to the community!

Errors like that are a very common problem when you create a source file that includes windows.h (or other Windows OS headers) and also third-party headers. The problem is that Windows has #defines for really common symbols like min and max (and many more), and these break all kinds of code.

I suspect your second change, adding NOMINMAX=1, will solve the problem even without the first change. Furthermore, you should be able to define that in your own module, rather than in CesiumRuntime.build.cs. That definition tells Windows not to define the min and max symbols. It will still define some other ones, though, that may still break all kinds of code.

The best solution is to isolate your Windows-specific code from your code that uses Unreal, Cesium, or pretty much anything else. It’s usually not necessary to use Windows APIs at all in an Unreal application, because Unreal has a portability layer for most platform-specific functionality. Sometimes third-party libraries include windows.h, though. But this is such a common issue that there’s usually a way around it.

1 Like