【问题标题】:HDF5 C++ Qt conflicting declarationHDF5 C++ Qt 冲突声明
【发布时间】:2018-11-27 04:59:19
【问题描述】:

情况:我需要读取一个.hdf5 文件并在使用Qt 创建的界面中以图形方式显示数据。

我做了什么:我创建了一个新项目,除了将 hdf5.lib 作为外部库添加到 hdf5_test.pro 之外,使用 qt 向导和 #include <hdf5.h>mainwindow.h

问题: 尝试运行代码时,我得到了这个Errorconflicting declaration 'typedef long long ssize_t'


使用:

  • C++
  • Qt 5.10.1
  • MinGW 5.3.0 32bit for C++
  • 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 可能是一个类似的问题,但没有答案。

【问题讨论】:

    标签: c++ qt declaration hdf5


    【解决方案1】:

    这是一个 hack,但 hdf5.h 检查 H5_SIZEOF_SSIZE_T 是否等于零。所以使用一个

    #define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
    

    在包含 hdf5.h 之前不重新定义类型可能会有所帮助。

    【讨论】:

    • 这解决了我的问题,但后来导致了一堆错误。我用 MSVC17 编译,一切正常。
    猜你喜欢
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    • 2012-05-09
    • 1970-01-01
    • 2018-03-30
    • 2019-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多