Skip to content

Compilation ifdefs #1279

@mheh

Description

@mheh

Hi all,

I'm sorry I couldn't find a template to fill out, though this isn't a bug request. I've been toying around with apple's C++ interop with Swift packages. I've gotten codemp to compile and on/off build but only when I compile it as a static library. When set as a dynamic lib (as it should be) it fails with unknown symbols. Here is my Package.swift setup:

// swift-tools-version: 6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
    name: "JediAcademy",
    defaultLocalization: "en",
    platforms: [
        .macOS(.v13),
    ],
    products: [
        .library(name: "codemp_game", type: .dynamic, targets: ["codemp_game"]),
    ],
    targets: [
        .target(
            name: "codemp_game",
            path: "Sources/codemp/game",
            publicHeadersPath: "./",
            cxxSettings: [
                .define("_GAME"),
                .headerSearchPath("../"),
                .headerSearchPath("../../shared"),
            ],
            swiftSettings: [
                .unsafeFlags(["-cxx-interoperability-mode=default"]),
            ]
        ),
    ]
)

A hypothesis is I might need another #ifdef flag declared since this is outside using CMAKE. Without _GAME it automatically fails at Line 259 of NPC_AI_ImperialProbe.c: if ( NPC_GetMoveDirection( forward, &distance ) == qfalse ) with Call to undeclared function 'NPC_GetMoveDirection';. However with _GAME defined, I reach the linking step. There are about 76 undefined symbols in the linking phase. It behaves like it doesn't find codemp/qcommon/q_shared.c functions. Since the errors are similar maybe it's a deeper issue I'm unaware of.

Anyway, thought this might be interesting.

EDIT:
sorry I almost forgot. The actual error is

Undefined symbols for architecture arm64:
"_AddPointToBounds", referenced from:
      _Think_SpawnNewDoorTrigger in g_mover.c.o
      _Think_SpawnNewDoorTrigger in g_mover.c.o
// etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions