问题
Situation: I want to create a program to read something from a .hdf5 file.
What i did: Nothing, but adding the hdf5.lib to the project.
Problem:
I get two Errors
when i try to run the program.
cannot find -lhdf5d
error: ld returned 1 exit status
My Code:
HDF5_Test.pro:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
win32:CONFIG(release, debug|release): LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5
else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5d
else:unix: LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5
INCLUDEPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
DEPENDPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
main.cpp:
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG //this is needed to avoid redefinition conflict of ssize_t (Qt vs HDF5)
#include <hdf5.h>
#include <H5Cpp.h> //Tried with and without this include
int main()
{
return 0;
}
Using:
- C++
- Qt 5.10.1
- MinGW 32bit
- HDF5 1.10.2
- Windows 7
In another project for whatever reason these Errors doesn't occur, but these.
.
回答1:
I linux, using apt-get install libhdf5-dev we get 8 libs installed but none is lihdf5 in its "nature". What i mean by that is that my include would be -lhdf5_openmpi and not-lhdf5. as you didn't provide the download source, try to check if you have multiple libs in your /lib file
回答2:
The Solution was for me to delete the final "d" in this line:
else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5d
Meaning i changed -lhdf5d to -lhdf5.
This problem was fixed this way but lead to another problem.
来源:https://stackoverflow.com/questions/50930693/c-hdf5-cannot-find-lhdf5d