Skip to content

Conversation

@jduffie
Copy link

@jduffie jduffie commented Jul 10, 2025

Hi all,
I'm John Duffie and have worked with Sam Hatchett. I wanted to run the tool to generate some simulated data but was unable to get it to compile. Below is the auto-generated PR. I ran the builds from within a docker container based on debian:bookworm-slim. I can pass the Dockerfile along if interested.

Fix linker errors and build dependencies for EPANET-MSX

Summary

This PR resolves multiple definition linker errors and missing library dependencies that prevented successful compilation of EPANET-MSX, enabling the full build process to complete successfully.

Changes Made

1. Fixed Multiple Definition Linker Errors in MSX Core

  • Problem: Function pointers (MSXgetPipeRates, MSXgetTankRates, etc.) were declared without extern in msxfuncs.h, causing multiple definitions across source files
  • Solution:
    • Added extern keyword to function pointer declarations in MSX Core/src/msxfuncs.h (lines 21-26)
    • Added actual definitions with NULL initialization in MSX Core/src/msxfuncs.c (lines 38-43)

2. Fixed Math Library Linking in Legacy DLL

  • Problem: Missing math library caused undefined references to sin, cos, exp, log, etc. on Linux builds
  • Solution: Added -lm (math library) to target_link_libraries for non-MSVC builds in Legacy DLL/CMakeLists.txt (line 58)

3. Enabled docker_embedded_build.sh Script

  • Problem: Build commands were commented out, making the script non-functional
  • Solution: Uncommented cmake .. and cmake --build . --config Release commands (lines 7-8)

Build Verification

All modules now build successfully using Docker:

  • ✅ MSX Core: libmsxcore.so and libmsxcore_lib.a
  • ✅ Legacy DLL: liblegacymsx.so
  • ✅ Examples: libexamples.so
  • ✅ CLI: runepanetmsx executable

Test Plan

  • Clean build of MSX Core module
  • Clean build of Legacy DLL with EPANET dependency
  • Clean build of Examples module
  • Clean build of CLI executable
  • Full build process using build.sh script
  • Docker-based build using docker_embedded_build.sh

Backward Compatibility

These changes maintain full backward compatibility:

  • No API changes
  • No functional changes to existing code
  • Only build system and linkage fixes

Related Issues

Fixes build failures that prevented compilation on Linux systems with recent GCC versions.

This PR description summarizes the key technical fixes needed to resolve the build errors and demonstrates that all components now build successfully.

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.

1 participant