Ninja + clang + CMake + bash + Windows: linker failure

I’m trying to link HDF5 in my GitHub Action CI. And I’m getting linker failures, even though HDF5 shows up in the linker arguments.

I am trying to link HDF5 using CMake as follows:

set(test_name "unit-tests")
find_package(HDF5 REQUIRED)
target_link_libraries(${test_name} PRIVATE ${HDF5_LIBRARIES})

Then, on my GitHub action:

        shell: bash -l {0}

    name: "${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
    runs-on: ${{ matrix.runs-on }}



    - name: Configure using CMake
      run: cmake -Bbuild -G Ninja

    - name: Build C++
      working-directory: build
      run: cmake --build .

With this I’m getting the error that

Linking CXX executable test\unit-tests.exe
FAILED: test/unit-tests.exe 
cmd.exe /C "cd . && C:\Miniconda\envs\myenv\Library\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt  test/CMakeFiles/unit-tests.dir/main.cpp.obj test/CMakeFiles/unit-tests.dir/Redraw.cpp.obj test/CMakeFiles/unit-tests.dir/Static.cpp.obj -o test\unit-tests.exe -Xlinker /implib:test\unit-tests.lib -Xlinker /pdb:test\unit-tests.pdb -Xlinker /version:0.0   C:/Miniconda/envs/myenv/Library/lib/libhdf5.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: undefined symbol: __declspec(dllimport) H5Pclose

(and many more of these linker errors).

For full reference : Debugging HighFive by tdegeus · Pull Request #19 · tdegeus/QPot · GitHub

I followed up on the issue you provided as a reference, and based on this comment looks like the issue disappeared as you confirmed there?

Is it possible this isn’t actually a GitHub Action issue, but something related to the project and the way it gets built?

Hi @lirantal . Thanks for your reply. I keep having problems with HDF5, but you are right that this is is maybe not the best platform for this question…