implement hdf5 in eclipse cdt for a c tool


#1

hi i m looking for a good tutrial to include the hdf5 lib in my eclipse cdt toolchain im using mingw32 as compiler and cant find any tutorial which descripes fully how to do it. If i found a link for a tutorial it was anytimes a dead link.
What i did so far:
-download and installed hdf5 with the msi installer and tryed to link it in the project under c/c++ build -> Settings ->Tool Settings tab -> Miscellaneous->other objects and set “path of install folder”\1.13.1\bin\hdf5.dll

didnt worked console output was
C:/Program Files/HDF_Group/HDF5/1.13.1/bin/hdf5.dll: file not recognized: File format not recognized

than i tried to set it in project properties-> C/C++ General-> Paths and Symbols under libraries tab i added hdf5.dll (with full path and without) and also i set the path in Library Path

didnt worked console output
C:/Program Files/HDF_Group/HDF5/1.13.1/bin/hdf5.dll: file not recognized: File format not recognized

than i tried to download the mingw ackage with the pacman from msys this only worked for 64 bit but i need 32 bit

can someone please please help me like i said any link i found to a tutorial is dead or for vs but need it for eclipse

thanks in advance Sebastian


#2

You will need to build hdf5 as all the download binaries are for 64-bit.


#3

I don’t use Eclipse.
Historically being a Linux guy, I have started to migrate to Windows using MSYS2 / MinGW64.
I am curious to know why you need 32-bit, when chances are your Windows client already is 64-bit.

Sorry to hear you use Eclipse. If you learned how to build from the command line, you would only need to learn one thing, once and for all; with IDE’s, you need to read the docs for that particular IDE.


#4

weil das Programm auf einen 32 bit system laufen muss deshalb geht meines wissens nach 64 bit nicht. Weißt du denn wie ich mit cmds die lib erstellen kann so das ich sie in mein project erstellen einfügen kann salazar?


#5

What happened there?

Don’t let my name mislead you, I am not from Germany and I don’t speak German; I am of Spanish descent and my proper name is Germán (but that accent often does not get included in my e-mail addresses).

Cheers


#6

ah sorry my mistake so in englisch again i need to do it in 32 bit bc the target system is just 32 bit. i tried to follow this tutorial https://github.com/long-gong/HDF5-with-MinGW found a error in the cmd:
cmake -G “MinGW Makefiles” -DCMAKE_BUILD_TYPE:STRING=Release -DHDF5_BUILD_FORTRAN:BOOL=OFF -DHDF5_BUILD_JAVA:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=\path\to\install\HDF5 DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF -DBUILD_TESTING:BOOL=ON -DHDF5_BUILD_TOOLS:BOOL=ON …\hdf5-1.10.5

where a “-” is missing so corrected it is :
cmake -G “MinGW Makefiles” -DCMAKE_BUILD_TYPE:STRING=Release -DHDF5_BUILD_FORTRAN:BOOL=OFF -DHDF5_BUILD_JAVA:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=\path\to\install\HDF5 -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF -DBUILD_TESTING:BOOL=ON -DHDF5_BUILD_TOOLS:BOOL=ON …\hdf5-1.10.5
than i run mingw-make but this throws lot of error which i put in a txt file and attach it here
mingw-make-errors.txt (42.7 KB)
can u maybe check it and help me


#7

I may have time to take a look later.
I am totally new to hdf5, but I just built it for Linux.
Also, I am already setup to use MinGW and GCC on my Windows machine.
We shall see.
Having said, it does not look like A LOT OF ERRORS; most are warnings and notes, there are only 2 errors.


#8

Update: I just realized that you are using cmake…I typically (like never) use cmake.

As a matter of habit, I downloaded the *.tar file for hdf5 to my Windows machine, opened a bash terminal and simply started to do what I always do: ./configure, make, make install…
…it is working, but it is taking forever…I am spoiled by the Linux machines, my Windows machine seems to be about 2 orders of magnitude slower than Linux. I am going to let it be; maybe tomorrow I will try with cmake.


#9

In the meantime, maybe you should try the ./configure, make, make install route.
You may start with something like this:

$export JAVA_HOME=/c/path/to/java
$export PATH=$JAVA_HOME/bin:$PATH
$./configure --prefix=/c/myprograms/hdf5/1.12.2/win10 \
        --enable-build-mode=production \
        --enable-fortran \
        --enable-cxx \
        --enable-java \
        --enable-shared \
        --enable-tools \
        --with-pic
$make
.
.
.

#10

changed the cmds to:
$export PATH=/c/mingw/bin:$PATH
$ ./configure --prefix=/c/myprograms/hdf5/1.12.2/win10 --enable-build-mode=production --enable-fortran --enable-cxx --enable-shared --enable-tools --with-pic

Output:

SUMMARY OF THE HDF5 CONFIGURATION
=================================

General Information:

               HDF5 Version: 1.12.2
              Configured on: Thu Jul 21 10:30:39 CEST 2022
              Configured by: Seppel@scio-nb017
                Host system: x86_64-pc-msys
          Uname information: MSYS_NT-10.0-19044 scio-nb017 3.3.5-341.x86_64 2022-05-30 21:10 UTC x86_64 Msys
                   Byte sex: little-endian
         Installation point: /c/myprograms/hdf5/1.12.2/win10

Compiling Options:

                 Build Mode: production
          Debugging Symbols: no
                    Asserts: no
                  Profiling: no
         Optimization Level: high

Linking Options:

                  Libraries: static

Statically Linked Executables:
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries: -lm
Archiver: ar
AR_FLAGS: cr
Ranlib: ranlib

Languages:

                          C: yes
                 C Compiler: /c/mingw/bin/gcc
                   CPPFLAGS:
                H5_CPPFLAGS:   -DNDEBUG -UH5_DEBUG_API
                AM_CPPFLAGS:
                    C Flags:
                 H5 C Flags:
                 AM C Flags:
           Shared C Library: no
           Static C Library: yes


                    Fortran: yes
           Fortran Compiler: /c/mingw/bin/gfortran
              Fortran Flags:
           H5 Fortran Flags:
           AM Fortran Flags:
     Shared Fortran Library: yes
     Static Fortran Library: yes

                        C++: yes
               C++ Compiler: /c/mingw/bin/g++
                  C++ Flags:
               H5 C++ Flags:
               AM C++ Flags:
         Shared C++ Library: no
         Static C++ Library: yes

                       Java: no

Features:

                 Parallel HDF5: no

Parallel Filtered Dataset Writes: no
Large Parallel I/O: no
High-level library: yes
Dimension scales w/ new references: no
Build HDF5 Tests: yes
Build HDF5 Tools: yes
Threadsafety: no
Default API mapping: v112
With deprecated public symbols: yes
I/O filters (external):
MPE: no
Map (H5M) API: no
Direct VFD: no
Mirror VFD: no
(Read-Only) S3 VFD: no
(Read-Only) HDFS VFD: no
dmalloc: no
Packages w/ extra debug output: none
API tracing: no
Using memory checker: no
Memory allocation sanity checks: no
Function stack tracing: no
Use file locking: best-effort
Strict file format checks: no
Optimization instrumentation: no

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

than i wanted do make:

Seppel@scio-nb017 MSYS /d/Projects/Windows/myhdf5/hdf5-1.12.2
$ mingw32-make

Output:
Making all in src
/usr/bin/sh: line 21: make: command not found
Makefile:723: recipe for target ‘all-recursive’ failed
mingw32-make: *** [all-recursive] Error 1
:frowning:


#11

u dont have to try cmake for me if u say its working without for you maybe we find a way thats working for me to i just want the debugable libs out of it no matter how we did it ty

Sebastian


#12

Just make a copy of minw32-make.exe and call it make.exe


#13

that worked but than this

CC H5Ztrans.lo
CCLD libhdf5.la
.libs/H5FDstdio.o:H5FDstdio.c:(.text+0x91f): undefined reference to fseeko' .libs/H5FDstdio.o:H5FDstdio.c:(.text+0x93d): undefined reference toftello’
.libs/H5FDstdio.o:H5FDstdio.c:(.text+0x12d3): undefined reference to fseeko' .libs/H5FDstdio.o:H5FDstdio.c:(.text+0x1880): undefined reference tofseeko’
.libs/H5PLpath.o:H5PLpath.c:(.text+0x5f4): undefined reference to strtok_r' .libs/H5PLpath.o:H5PLpath.c:(.text+0x6b1): undefined reference tostrtok_r’
.libs/H5VLint.o:H5VLint.c:(.text+0x996): undefined reference to strtok_r' .libs/H5VLint.o:H5VLint.c:(.text+0xd87): undefined reference tostrtok_r’
collect2.exe: error: ld returned 1 exit status
Makefile:1191: recipe for target ‘libhdf5.la’ failed
make[2]: *** [libhdf5.la] Error 1
make[2]: Leaving directory ‘D:/Projects/Windows/myhdf5/hdf5-1.12.2/src’
Makefile:1103: recipe for target ‘all’ failed
make[1]: *** [all] Error 2
make[1]: Leaving directory ‘D:/Projects/Windows/myhdf5/hdf5-1.12.2/src’
Makefile:723: recipe for target ‘all-recursive’ failed
make: *** [all-recursive] Error 1


#14

is ./configure doing config it automaticaly in 32 bit maybe this error are problems between 64 config and 32 bit compiler? If i have to set a flag for 32 bit how i would do this?

ok i found out that at least the strtok_r function is not part of mingw32 but what i can now here just write it by my own or is there a config/complier flag that i have to set?


#15

was able to solve this by setting the strtok_r to strtok but after this more and more function appear which are not in mingw32 did i something wrong here with flags or something else?


#16

I don’t know the answers to all those questions; I wouldn’t know what to do, either, if ./configure, make and make install does not work out of the box.

I will report my troubles a bit later…and I do have troubles, too…the same sources that I built on Linux, are not building on Windows.


#17

I did not get too far in the compilation process, either; the same sources I built in Linux are not building on Windows. Here are the 2 error messages that cause termination:

In file included from H5PLint.c:30:
H5PLint.c: In function 'H5PL__open':
H5PLpkg.h:97:33: warning: implicit declaration of function 'dlopen'; did you mean 'fdopen'? [-Wimplicit-function-declaration]
   97 | #define H5PL_OPEN_DLIB(S)       dlopen(S, RTLD_LAZY | RTLD_LOCAL)
      |                                 ^~~~~~
H5PLpkg.h:97:43: error: 'RTLD_LAZY' undeclared (first use in this function)
   97 | #define H5PL_OPEN_DLIB(S)       dlopen(S, RTLD_LAZY | RTLD_LOCAL)
      |                                           ^~~~~~~~~
H5PLpkg.h:97:55: error: 'RTLD_LOCAL' undeclared (first use in this function)
   97 | #define H5PL_OPEN_DLIB(S)       dlopen(S, RTLD_LAZY | RTLD_LOCAL)
      |                                                       ^~~~~~~~~~

#18

Yes, windows does not have dlopen as it uses a different method. You will need to find a mingw version.


#19

Update.

I just learned a few of things.

That dlopen for mingw does exist; I just installed it in my instance of msys2/mingw64:

pacman -S mingw-w64-x86_64-dlfcn

That this package provides library dl (/mingw64/lib/libdl.a).

Went back to take a look at the output from my initial ./configure and found this:

.
.
checking for dlfcn.h... no               # <----- ojo
.
.
checking for ceil in -lm... yes
checking for dlopen in -ldl... no        # <----- ojo
checking for ANSI C header files... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking dirent.h usability... yes
.
.

Started over and re-run ./configure; this time, I get:

checking for dlfcn.h... yes              # <----- ojo
.
.
checking for dlopen in -ldl... yes       # <----- ojo

…so, that’s how that works.


#20

if u use mingw 64 bit u can just pacman the whole hdf5 package but i was looking for mingw32 bit