Tracktion / choc

A collection of header only classes, permissively licensed, to provide basic useful tasks with the bare-minimum of dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with GitHub workflow build

daveboulden opened this issue · comments

I am having difficulty getting my second project to build a MacOS binary. The Windows build works just fine. My first project worked just fine for both MacOS and Windows (https://github.com/daveboulden/gp-basic-songchooser/actions/runs/6123897797/workflow), but the second one using the same build.yaml is failing:

[100%] Linking CXX shared library libAdvancedSongChooser.dylib
Undefined symbols for architecture arm[64](https://github.com/BOULDEN-digital/gp-advanced-songchooser/actions/runs/6207322353/job/16852452521#step:7:65):
  "_class_addMethod", referenced from:
      choc::ui::DesktopWindow::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::WebviewClass::WebviewClass() in LibMain.cpp.o
  "_class_addProtocol", referenced from:
      choc::ui::DesktopWindow::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
  "_objc_allocateClassPair", referenced from:
      choc::objc::createDelegateClass(char const*, char const*) in LibMain.cpp.o
  "_objc_disposeClassPair", referenced from:
      choc::ui::DesktopWindow::Pimpl::DelegateClass::~DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::DelegateClass::~DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::WebviewClass::~WebviewClass() in LibMain.cpp.o
  "_objc_getAssociatedObject", referenced from:
      choc::ui::DesktopWindow::Pimpl::getPimplFromContext(objc_object*) in LibMain.cpp.o
      choc::ui::WebView::Pimpl::DelegateClass::DelegateClass()::'lambda'(objc_object*, objc_selector*, objc_object*, objc_object*)::operator()(objc_object*, objc_selector*, objc_object*, objc_object*) const in LibMain.cpp.o
      choc::ui::WebView::Pimpl::DelegateClass::DelegateClass()::'lambda0'(objc_object*, objc_selector*, objc_object*, objc_object*)::operator()(objc_object*, objc_selector*, objc_object*, objc_object*) const in LibMain.cpp.o
      choc::ui::WebView::Pimpl::WebviewClass::WebviewClass()::'lambda'(objc_object*, objc_selector*, objc_object*)::operator()(objc_object*, objc_selector*, objc_object*) const in LibMain.cpp.o
  "_objc_getClass", referenced from:
      choc::objc::getClass(char const*) in LibMain.cpp.o
      choc::objc::createDelegateClass(char const*, char const*) in LibMain.cpp.o
  "_objc_getProtocol", referenced from:
      choc::ui::DesktopWindow::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
  "_objc_msgSend", referenced from:
      void choc::objc::call<void, objc_object*, objc_object*>(objc_object*, char const*, objc_object*, objc_object*) in LibMain.cpp.o
      objc_object* choc::objc::call<objc_object*>(objc_object*, char const*) in LibMain.cpp.o
      objc_object* choc::objc::call<objc_object*, char const*>(objc_object*, char const*, char const*) in LibMain.cpp.o
      void choc::objc::call<void>(objc_object*, char const*) in LibMain.cpp.o
      void choc::objc::call<void, objc_object*>(objc_object*, char const*, objc_object*) in LibMain.cpp.o
      void choc::objc::call<void, unsigned long>(objc_object*, char const*, unsigned long) in LibMain.cpp.o
      void choc::objc::call<void, choc::ui::(anonymous namespace)::CGRect, bool, bool>(objc_object*, char const*, choc::ui::(anonymous namespace)::CGRect, bool, bool) in LibMain.cpp.o
      ...
  "_objc_registerClassPair", referenced from:
      choc::ui::DesktopWindow::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::DelegateClass::DelegateClass() in LibMain.cpp.o
      choc::ui::WebView::Pimpl::WebviewClass::WebviewClass() in LibMain.cpp.o
  "_objc_setAssociatedObject", referenced from:
      choc::ui::WebView::Pimpl::~Pimpl() in LibMain.cpp.o
      choc::ui::DesktopWindow::Pimpl::Pimpl(choc::ui::DesktopWindow&, choc::ui::Bounds) in LibMain.cpp.o
      choc::ui::WebView::Pimpl::Pimpl(choc::ui::WebView&, choc::ui::WebView::Options const&) in LibMain.cpp.o
  "_sel_registerName", referenced from:
      void choc::objc::call<void, objc_object*, objc_object*>(objc_object*, char const*, objc_object*, objc_object*) in LibMain.cpp.o
      objc_object* choc::objc::call<objc_object*>(objc_object*, char const*) in LibMain.cpp.o
      objc_object* choc::objc::call<objc_object*, char const*>(objc_object*, char const*, char const*) in LibMain.cpp.o
      void choc::objc::call<void>(objc_object*, char const*) in LibMain.cpp.o
      void choc::objc::call<void, objc_object*>(objc_object*, char const*, objc_object*) in LibMain.cpp.o
      void choc::objc::call<void, unsigned long>(objc_object*, char const*, unsigned long) in LibMain.cpp.o
      void choc::objc::call<void, choc::ui::(anonymous namespace)::CGRect, bool, bool>(objc_object*, char const*, choc::ui::(anonymous namespace)::CGRect, bool, bool) in LibMain.cpp.o
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libAdvancedSongChooser.dylib] Error 1
make[1]: *** [CMakeFiles/AdvancedSongChooser.dir/all] Error 2
make: *** [all] Error 2
Error: Process completed with exit code 2.

my build.yaml looks like this:

name: Build
on:
    pull_request:
        branches: ["choc-conversion"]
    push:
        branches: ["choc-conversion"]

permissions:
    repository-projects: read

jobs:
    build:
        name: Plugins and Packages - ${{ matrix.config.name }}
        runs-on: ${{ matrix.config.os }}
        strategy:
            # If the job fails for one config, don't abort the jobs for the other configs
            fail-fast: false
            matrix:
                config:
                    - name: "macOS - universal"
                      os: "macos-11"
                      cmake_preset: "mac-universal"
                      build_config: "Release"
                    - name: "Windows"
                      os: "windows-2019"
                      cmake_preset: "windows-native"
                      build_config: "Release"
        env:
            # Unfortunately, Ccache is not available yet for Windows and MSVC
            CCACHE_AVAILABLE: ${{ matrix.config.os == 'macos-11' }}

            # To store the build extension later, we store it inside the build cache
            CMAKE_ADDITIONAL_OPTIONS: "-D 'GIG_PERFORMER_EXTENSIONS_DIRECTORY=${{ github.workspace }}/build/install'"
        steps:
            - name: Checkout
              uses: actions/checkout@v3
              with:
                repository: BOULDEN-digital/gp-advanced-songchooser
                token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            - name: "Ccache"
              uses: hendrikmuhs/ccache-action@ed038da2f2f09b0c8387c00e1498290a4808da2e # v1.2.2
              if: env.CCACHE_AVAILABLE == 'true'
              with:
                  key: ${{ matrix.config.os }}-${{ matrix.config.cmake_preset }}
                  max-size: 1536M
            - name: "Ccache: Clear"
              # We are triggered by the "push" event in the case of release branches.
              # For these branches, no cache shall be used - but we still use the
              # Ccache compiler driver in order to build up a cache that pull requests
              # targeting this branch can use.
              if: env.CCACHE_AVAILABLE == 'true' && github.event_name == 'push'
              run: ccache --clear
            - name: "Ccache: Enable compiler driver"
              if: env.CCACHE_AVAILABLE == 'true'
              run: echo "CMAKE_ADDITIONAL_OPTIONS=${{ env.CMAKE_ADDITIONAL_OPTIONS }} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
            - name: "CMake: Configure"
              run: cmake -S . --preset=${{ matrix.config.cmake_preset }} ${{ env.CMAKE_ADDITIONAL_OPTIONS }}
            - name: "CMake: Build"
              run: cmake --build --preset=${{ matrix.config.cmake_preset }} --config ${{ matrix.config.build_config }} --parallel
            - name: "CMake: Install"
              run: cmake --install build/${{ matrix.config.cmake_preset }} --config ${{ matrix.config.build_config }}
            - name: Store extension
              uses: actions/upload-artifact@v3
              with:
                  name: extension
                  path: build/install

I have done a lot of Googling but am not sure even where to concentrate to find the issue. Could you offer any pointers to set me in the right direction, please?

Those symbols are all from libobjc, so presumably you're not linking to that library.

Thank you for the pointer, Julian. Just adding what turned out to be my solution in case anyone else might make the same mistake as me. I had forgotten to also link WebKit and CoreServices for MacOS builds in CMakeLists.txt. In my case I changed it to target link libraries differently between MacOS and Windows:

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    target_link_libraries(${PROJECT_NAME} PRIVATE   gigperformer::sdk::cpp
                                                    nlohmann_json::nlohmann_json
                                                    "-framework WebKit -framework CoreServices")
else ()
    target_link_libraries(${PROJECT_NAME} PRIVATE   gigperformer::sdk::cpp
                                                    nlohmann_json::nlohmann_json)
endif ()