我有特定的要求,我想编译和执行一些具有HDF5依赖关系的代码。
我不想使用/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This example illustrates how to create a dataset that is a 4 x 6
* array. It is used in the HDF5 Tutorial.
*/
#include "hdf5.h"
#define FILE "dset.h5"
int main() {
hid_t file_id, dataset_id, dataspace_id; /* identifiers */
hsize_t dims[2];
herr_t status;
/* Create a new file using default properties. */
file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create the data space for the dataset. */
dims[0] = 4;
dims[1] = 6;
dataspace_id = H5Screate_simple(2, dims, NULL);
/* Create the dataset. */
dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* End access to the dataset and release resources used by it. */
status = H5Dclose(dataset_id);
/* Terminate access to the data space. */
status = H5Sclose(dataspace_id);
/* Close the file. */
status = H5Fclose(file_id);
}
,但我想编译HDF5源代码。
我对如何将HDF5链接到我的C程序非常新。请您详细解释如何操作,这样我就可以使用c编译器执行此程序并链接从here下载的源文件。
示例C程序 -
{
"queryType":"SQL",
"query": "CREATE TABLE st.`repo`.`test` AS SELECT * FROM st.`repo`.`unicode_data`"
}
答案 0 :(得分:3)
对于编译,必须将-I
标志指向HDF5的include目录。对于系统安装,它通常为/usr/include
,但有许多变化,具体取决于HDF5是以串行还是并行方式安装,32/64位等。用于链接-L
和{{1标志是重要的。 -l
应该指向包含HDF5库的-L
,.so
或.dll
文件的目录(同样,可能有变体),而.dylib
只是简单地给出库名称-l
和其他名称(我相信-lhdf5
和-lz
几乎总是被使用)。如果您使用高级库,则需要-lm
。
检查这些标志的最简单方法是调用
-lhdf5_hl
将列出所有内容。
PS:您可以一步编译和链接(从h5cc -show
到可执行文件)或首先编译(.c
到.c
)然后链接(.o
到可执行文件)。在第一种情况下,需要所有.o
,-I
和-L
标记。