HDF5 C++ Qt 冲突声明
HDF5 C++ Qt conflicting declaration
情况: 我需要读取一个 .hdf5
文件并在使用 Qt 创建的界面中以图形方式显示数据。
我做了什么: 我创建了一个新项目,只是使用 qt 向导将 hdf5.lib
作为外部库添加到 hdf5_test.pro
为了做到这一点和 #include <hdf5.h>
在 mainwindow.h
问题:
当尝试 运行 代码时,我得到这个 Error: conflicting declaration 'typedef long long ssize_t'
使用:
- C++
- Qt 5.10.1
- 用于 C++ 的 MinGW 5.3.0 32 位
- HDF5 1.10.2
我的代码:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <hdf5.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = hdf5_test
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
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'
This 可能是一个类似的问题,但没有答案。
这是一个 hack,但 hdf5.h 检查 H5_SIZEOF_SSIZE_T
是否等于零。所以使用
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
在包含 hdf5.h 之前可以通过不重新定义类型来提供帮助。
情况: 我需要读取一个 .hdf5
文件并在使用 Qt 创建的界面中以图形方式显示数据。
我做了什么: 我创建了一个新项目,只是使用 qt 向导将 hdf5.lib
作为外部库添加到 hdf5_test.pro
为了做到这一点和 #include <hdf5.h>
在 mainwindow.h
问题:
当尝试 运行 代码时,我得到这个 Error: conflicting declaration 'typedef long long ssize_t'
使用:
- C++
- Qt 5.10.1
- 用于 C++ 的 MinGW 5.3.0 32 位
- HDF5 1.10.2
我的代码:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <hdf5.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = hdf5_test
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
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'
This 可能是一个类似的问题,但没有答案。
这是一个 hack,但 hdf5.h 检查 H5_SIZEOF_SSIZE_T
是否等于零。所以使用
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
在包含 hdf5.h 之前可以通过不重新定义类型来提供帮助。