Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5 not properly linked on Windows + Bash + Ninja #422

Closed
tdegeus opened this issue Mar 23, 2021 · 8 comments
Closed

HDF5 not properly linked on Windows + Bash + Ninja #422

tdegeus opened this issue Mar 23, 2021 · 8 comments
Assignees
Labels
cmake Anything build-system (CMake) related.

Comments

@tdegeus
Copy link
Collaborator

tdegeus commented Mar 23, 2021

I am trying to link HDF5 using CMake as follows:

set(test_name "unit-tests")
set(HIGHFIVE_USE_BOOST 0)
set(HIGHFIVE_USE_XTENSOR 1)
find_package(HighFive REQUIRED)
target_link_libraries(${test_name} PRIVATE HighFive)

Then, on my GitHub action:

    defaults:
      run:
        shell: bash -l {0}

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

    steps:

    ...

    - 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 : tdegeus/QPot#19

@PhilipDeegan
Copy link
Contributor

You might be able to get around this by adding a define for

-DH5_BUILT_AS_DYNAMIC_LIB=1

https://github.com/HDFGroup/hdf5/blob/2ea165efd095d8876639814dc615dd01a2ec34e6/src/H5api_adpt.h#L23

@tdegeus
Copy link
Collaborator Author

tdegeus commented Mar 31, 2021

Thanks for the suggestion @PhilipDeegan , but unfortunately that did not fix... But it does suggest that I might be understanding things incorrectly. I thought that HDF5 might not be linked correctly, but your suggestion implies that it might be linked correctly, but that it might be missing some symbols because of the way HDF5 was coded?

@tdegeus
Copy link
Collaborator Author

tdegeus commented Mar 31, 2021

What is a bit strange is that I don't find something like -lhdf5 as argument, wheres the HighFive target clear does something (resulting in arguments like -DH5_USE_XTENSOR -DMPI_NO_CPPBIND):

[1/4] C:\Miniconda\envs\myenv\Library\bin\clang++.exe -DDH5_BUILT_AS_DYNAMIC_LIB -DH5_BUILT_AS_DYNAMIC_LIB -DH5_USE_XTENSOR -DMPI_NO_CPPBIND -DQPOT_ENABLE_ASSERT -DUSE_HDF5 -I../include -isystem C:/Miniconda/envs/myenv/Library/include -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -Wall -Wextra -pedantic -Wno-unknown-pragmas -MD -MT test/CMakeFiles/unit-tests.dir/Static.cpp.obj -MF test\CMakeFiles\unit-tests.dir\Static.cpp.obj.d -o test/CMakeFiles/unit-tests.dir/Static.cpp.obj -c ../test/Static.cpp
[2/4] C:\Miniconda\envs\myenv\Library\bin\clang++.exe -DDH5_BUILT_AS_DYNAMIC_LIB -DH5_BUILT_AS_DYNAMIC_LIB -DH5_USE_XTENSOR -DMPI_NO_CPPBIND -DQPOT_ENABLE_ASSERT -DUSE_HDF5 -I../include -isystem C:/Miniconda/envs/myenv/Library/include -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -Wall -Wextra -pedantic -Wno-unknown-pragmas -MD -MT test/CMakeFiles/unit-tests.dir/main.cpp.obj -MF test\CMakeFiles\unit-tests.dir\main.cpp.obj.d -o test/CMakeFiles/unit-tests.dir/main.cpp.obj -c ../test/main.cpp
[3/4] C:\Miniconda\envs\myenv\Library\bin\clang++.exe -DDH5_BUILT_AS_DYNAMIC_LIB -DH5_BUILT_AS_DYNAMIC_LIB -DH5_USE_XTENSOR -DMPI_NO_CPPBIND -DQPOT_ENABLE_ASSERT -DUSE_HDF5 -I../include -isystem C:/Miniconda/envs/myenv/Library/include -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -Wall -Wextra -pedantic -Wno-unknown-pragmas -MD -MT test/CMakeFiles/unit-tests.dir/Redraw.cpp.obj -MF test\CMakeFiles\unit-tests.dir\Redraw.cpp.obj.d -o test/CMakeFiles/unit-tests.dir/Redraw.cpp.obj -c ../test/Redraw.cpp
[4/4] 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 ."
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

@PhilipDeegan
Copy link
Contributor

you have

C:/Miniconda/envs/myenv/Library/lib/libhdf5.lib

if you have no dll, you might only have a static library version of hdf5

@pramodk pramodk added the windows label Apr 9, 2021
@tdegeus
Copy link
Collaborator Author

tdegeus commented Jun 11, 2021

The problems curiously disappeared from me. This might be due to a HDF5 and/or CMake update

@tdegeus tdegeus closed this as completed Jun 11, 2021
@tdegeus
Copy link
Collaborator Author

tdegeus commented Jun 11, 2021

And curiously reappeared here: tdegeus/XDMFWrite_HighFive#11

@tdegeus tdegeus reopened this Jun 11, 2021
@1uc 1uc added the cmake Anything build-system (CMake) related. label Mar 17, 2023
@1uc
Copy link
Collaborator

1uc commented May 5, 2023

@tdegeus Is this still an issue or can we close this?

@1uc
Copy link
Collaborator

1uc commented Feb 13, 2024

We've rewritten the HighFive CMake related code for v3 and are close to of have merge the changes. I'm closing this issue as outdated. Please open a new Issue if the problem persists after #897 got merged.

@1uc 1uc closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Anything build-system (CMake) related.
Projects
None yet
Development

No branches or pull requests

5 participants