Skip to content

macOS build fails: WSTP symbols undefined when linking libHypergraphRewriting.dylib #1

Description

@sashakolpakov

Summary

On macOS the paclet library fails to link (compilation succeeds):

[ 47%] Linking CXX shared library .../MacOSX-ARM64/libHypergraphRewriting.dylib
Undefined symbols for architecture arm64:
  "_WSNewPacket", referenced from: _performRewriting in hypergraph_ffi.cpp.o ...
  "_WSNextPacket", ...
  "_WSPutFunction", ...
  "_WSPutString", ...
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1
make: *** [paclet] Error 2

Root cause

In paclet_source/CMakeLists.txt, the WSTP block has three platform branches.
The Windows and Linux branches each link the WSTP library
(wstp64i4.lib / libWSTP64i4.so), but the Darwin branch only sets
HAVE_WSTP=1 and adds the include directory — it never links libWSTPi4.a.

So hypergraph_ffi.cpp is compiled with the WSTP code path enabled
(WSNewPacket/WSNextPacket/WSPutFunction/WSPutString, used for progress
reporting) but those symbols are never resolved at link time.

Reproduce

./build_all_platforms.sh on macOS (Apple silicon, Wolfram 14+).

Fix

Link the macOS WSTP static library in the Darwin branch
(libWSTPi4.a, which additionally needs -framework Foundation — already added
in the Darwin linker block).

Related problems found while fixing this (also addressed in the PR)

  1. cmake/FindMathematica.cmake does not search
    /Applications/Wolfram.app/Contents — the install name used by Wolfram 14+
    on macOS — so the kernel is only found if MATHEMATICA_HOME is set manually.
  2. build_all_platforms.sh aborts the entire multi-platform run when the
    Windows-ARM64 configure step fails (it can only succeed on a Windows/WSL host
    with the Windows SDK). On macOS this kills the run before the macOS libraries
    are even built. It should skip host-impossible targets, not fail.
  3. There is no native macOS build path — the script routes macOS through
    OSXCross even when running on macOS, where Apple clang can target both
    arches natively.

A PR addressing all of the above follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions