Skip to content

Fix ResourceEventListener interface mismatch in sample apps and Windows build#3

Draft
Copilot wants to merge 15 commits intomasterfrom
copilot/distinguish-engine-and-build-library
Draft

Fix ResourceEventListener interface mismatch in sample apps and Windows build#3
Copilot wants to merge 15 commits intomasterfrom
copilot/distinguish-engine-and-build-library

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

  • Fix ResourceEventListener interface mismatch in sample apps
  • Fix initial Windows linker error (engineMain): NUTMEG_BUILD_DLL for NutmegCore.dll, winmain.cpp for sample executables
  • Fix second round of Windows build errors (NOMINMAX, Newton static lib, DLL export/import for templates, DevIL path, audio backend)
  • Fix third round: C2370 manager redefinition with different storage class in Resource.cpp
  • Fix fourth round: LNK2019 Subsystem<ResourceManager>::factory unresolved in NutmegCore.dll
    • IMP_SUBSYSTEM(ResourceManager) was never called anywhere, so Subsystem<ResourceManager>::factory had no definition
    • Added IMP_SUBSYSTEM(ResourceManager) to Resource.cpp (same pattern as AbstractAudio.cpp, AbstractRender.cpp, etc.)
  • Fix fifth round of Windows build errors:
    • LNK1181 NutmegLib.lib not found: NutmegLib was SHARED but OpenGL.cpp has no code, so MSVC never generates an import library — changed to STATIC
    • LNK2019 __imp_Newton* unresolved: Library/Newton/Newton.h (v2.30, found first on the include path) uses _NEWTON_USE_LIB not _NEWTON_STATIC_LIB to suppress __declspec(dllimport) on MSVC — fixed NutmegPhysics compile definition accordingly
    • C2512 AbstractRender no default constructor: RenderOpenGL2() tried to implicitly call AbstractRender() which doesn't exist (only AbstractRender(Engine*)) — added Engine* parameter to RenderOpenGL2 constructor and createRenderOpenGL2
    • C2259 RenderMeshOpenGL1 / RenderOpenGL2 abstract: multiple missing or misnamed pure virtual overrides (getTextWidth, drawBillboard, drawRotateManipulator, drawSolidCircle, drawCircle, setViewport, getPixelAspectRatio, setPixelAspectRatio, isAlphaTest, setAlphaTest, drawSkinnedMesh, getMesh) — corrected all signatures and added missing stubs
    • C2664 ilutGLLoadImage: legacy API takes char* but received const char* — fixed with const_cast<ILstring>
  • Fix sixth round of Windows build errors:
    • LNK2019 dot/cross/normalize: free functions declared only as friend inside class vec3 with no NUTMEG_API — added NUTMEG_API to friend declarations in MathCore.h
    • LNK2019 Scene::restore, getPhysicsWorld, setActiveCamera, getNodesCount: class Scene had no NUTMEG_API — added it
    • LNK2019 ParticleSystemNode::* methods: class ParticleSystemNode had no NUTMEG_API — added it
    • LNK2019 Integrator<vec3>::update, getPosDelta, constructor: template marked class NUTMEG_API Integrator causes dllimport in consumers but no explicit instantiation existed in the DLL — added template class NUTMEG_API Integrator<vec3> in MathCore.cpp (under NUTMEG_BUILD_DLL) and extern template in MathCore.h (under NUTMEG_USE_DLL)
  • Linux build verified: all targets build cleanly

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 27, 2026 04:11
Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copilot AI changed the title [WIP] Distinguish engine and build it as a library Fix ResourceEventListener interface mismatch in sample apps Feb 27, 2026
@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot we have problems building under windows, see build_errors.txt

… point for sample executables

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot we have problems building under windows, see build_errors.txt

Fixed in commit b976240.

Root cause: Engine.cpp contains WinMain (guarded by #ifndef NUTMEG_BUILD_DLL) which calls Nutmeg::engineMain(). When building NutmegCore.dll, engineMain is not defined in the DLL — it's provided by each sample app. Without NUTMEG_BUILD_DLL defined, WinMain ended up in the DLL and couldn't resolve engineMain.

Changes:

  • CoreSrc/CMakeLists.txt: define NUTMEG_BUILD_DLL (PRIVATE) for NutmegCore on Windows — this excludes WinMain from the DLL (via the existing #ifndef NUTMEG_BUILD_DLL guard in Engine.cpp) and enables proper __declspec(dllexport)/dllimport) via NUTMEG_API. NUTMEG_USE_DLL is propagated as INTERFACE so all consumers (subsystems, samples) automatically get __declspec(dllimport).
  • Samples/winmain.cpp: new shared WinMain that calls Nutmeg::engineMain(0, nullptr). Each sample executable links its own engineMain (Boets/DiabloRemix/EntitySample each define Nutmeg::engineMain in Source/main.cpp) — the linker resolves it to the sample-specific implementation.
  • Samples/Boets|DiabloRemix|EntitySample/CMakeLists.txt: on Windows, use WIN32 executable type and include ../winmain.cpp; Linux is unchanged.

Copilot AI changed the title Fix ResourceEventListener interface mismatch in sample apps Fix ResourceEventListener interface mismatch in sample apps and Windows build Feb 27, 2026
@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot see build_errors.txt again and fix it

…/import for templates, DevIL path, audio backend

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot see build_errors.txt again and fix it

Fixed in commit c54560e. Here's what was causing each error in build_errors.txt:

C2589 – math::min/math::max macro conflicts (Skeleton.h, EntityWeapon.h): <windows.h> (pulled in via DynLib.h) redefines min/max as macros after MathCore.h's #undef min/max. Fixed by adding NOMINMAX globally for Windows in CMakeLists.txt.

__imp_Newton* unresolved in NutmegPhysics: Library/Newton/Newton.h defaults to __declspec(dllimport) on Windows without _NEWTON_USE_LIB, but Newton is built as a static library. Fixed by adding _NEWTON_STATIC_LIB to NutmegPhysics compile definitions on Windows.

__imp_Subsystem<T>::addImplementation / Resource<T>::manager unresolved: These template static data members and methods need explicit DLL export/import. Fixed by:

  • Updating IMP_SUBSYSTEM macro to apply NUTMEG_API to the factory definition
  • Adding template class NUTMEG_API Subsystem<T> explicit instantiations in NutmegCore .cpp files (under NUTMEG_BUILD_DLL)
  • Adding extern template class NUTMEG_API Subsystem<T> in headers (under NUTMEG_USE_DLL) to suppress re-instantiation in consuming DLLs
  • Same pattern for Resource<T> in Resource.h/Resource.cpp

ResourceManager methods and findFile unresolved: Not decorated with NUTMEG_API so not exported from NutmegCore.dll. Fixed by adding NUTMEG_API to ResourceManager class and findFile.

il.h not found in NutmegRender: With Conan's DevIL, IL_INCLUDE_DIR isn't set (unlike the Linux find_package(DevIL) path). Fixed by extracting INTERFACE_INCLUDE_DIRECTORIES from the DevIL::IL Conan target and appending the IL subdirectory.

SQUALL_Init unresolved + init duplicate definition in NutmegAudio: The Squall library isn't in the repository, and both AudioDummy.cpp and AudioSquall.cpp define extern "C" void init(). Fixed by excluding AudioSquall.cpp and AudioBada.cpp from the Windows build.

@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot see build_errors.txt again and fix it

…alization definitions

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot see build_errors.txt again and fix it

Fixed in commit 9576d7d.

Root cause: MSVC C2370 — __declspec(dllexport) was applied via NUTMEG_API directly on the template <> explicit specialization definitions of Resource<T>::manager in Resource.cpp. MSVC rejects this because the manager member was declared without any __declspec attribute in the class body, so the definition has a "different storage class".

The template class NUTMEG_API Resource<T> explicit instantiations (added in the previous commit) already export the entire instantiation including the static manager member. Removed the redundant NUTMEG_API from the eight template <> ResourceMan<T> *TypeRef::manager = NULL definitions.

@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot see build_errors.txt again and fix it

…esourceManager>::factory

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot see build_errors.txt again and fix it

Fixed in commit 816e5e6.

Root cause: Subsystem<ResourceManager>::factory was never defined — IMP_SUBSYSTEM(ResourceManager) was missing from the codebase. The template class NUTMEG_API Subsystem<ResourceManager> explicit instantiation in Resource.cpp instantiates methods like addImplementation that reference factory, so the linker couldn't find the definition.

Added IMP_SUBSYSTEM(ResourceManager) to Resource.cpp, following the same pattern used by AbstractAudio.cpp, AbstractRender.cpp, AbstractPlatform.cpp, and AbstractPhysics.cpp.

@Evil-Spirit
Copy link
Copy Markdown
Owner

https://gh.io/copilot-coding-agent-docs see build_errors.txt again and fix it

@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot see build_errors.txt again and fix it

…WTON_USE_LIB, RenderOpenGL2 abstract class and constructor

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot see build_errors.txt again and fix it

Fixed in commit 9a997f1. Five root causes were identified and resolved:

  1. LNK1181 NutmegLib.lib: NutmegLib was SHARED but OpenGL.cpp has no code, so MSVC never generates an import library. Changed to STATIC.

  2. LNK2019 __imp_Newton*: Library/Newton/Newton.h (v2.30, found first in the global include path) uses _NEWTON_USE_LIB — not _NEWTON_STATIC_LIB — to disable __declspec(dllimport) on MSVC. Fixed by changing the compile definition in NutmegPhysics to _NEWTON_USE_LIB.

  3. C2512 AbstractRender no default constructor: RenderOpenGL2() tried to implicitly call AbstractRender() which doesn't exist (only AbstractRender(Engine*)). Fixed by adding Engine* to the constructor and createRenderOpenGL2.

  4. C2259 abstract class (RenderMeshOpenGL1 / RenderOpenGL2): Several pure virtual methods were missing or had mismatched signatures (getTextWidth, drawBillboard, drawRotateManipulator (was named renderRotateManipulator), drawSolidCircle, drawCircle, setViewport, getPixelAspectRatio, setPixelAspectRatio, isAlphaTest, setAlphaTest, drawSkinnedMesh, getMesh). All corrected.

  5. C2664 ilutGLLoadImage: Legacy API takes char* but received const char*. Fixed with const_cast<ILstring>.

@Evil-Spirit
Copy link
Copy Markdown
Owner

@copilot check build_errors.txt again and try to fix it finally.

…Scene, ParticleSystemNode, Integrator<vec3>

Co-authored-by: Evil-Spirit <1980537+Evil-Spirit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot check build_errors.txt again and try to fix it finally.

Fixed in commit 18b0ba8. Four categories of unresolved symbols addressed:

  1. LNK2019 dot/cross/normalize: These free functions were declared only as friend inside class vec3 without NUTMEG_API, so they weren't in the NutmegCore.dll export table. Added NUTMEG_API to the friend declarations.

  2. LNK2019 Scene::* (restore, getPhysicsWorld, setActiveCamera, getNodesCount): class Scene was missing NUTMEG_API. Added it.

  3. LNK2019 ParticleSystemNode::*: class ParticleSystemNode was missing NUTMEG_API. Added it.

  4. LNK2019 Integrator<vec3>::update/getPosDelta/ctor: The Integrator<T> template already had class NUTMEG_API Integrator on the declaration, so with NUTMEG_USE_DLL consumers tried to dllimport these methods — but no explicit instantiation existed in the DLL. Added template class NUTMEG_API Integrator<vec3> to MathCore.cpp (under NUTMEG_BUILD_DLL) and extern template in MathCore.h (under NUTMEG_USE_DLL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants