We are creating an application for a PXI running NI RT Linux with LV 2020 installed. I'm not really familiar with building so files for linux, but I looked up how to build, so i prepped my NI RT device with the build tools (make, gcc, etc) and copied the contents of the lib directory to the device.
I tried to build using
gcc -c -fPIC h5labview.c -o h5labview.o
Hello Bas,
You need to install "libhdf". Any standard distro package manager should provide it precompiled or ported (you will likely need the "devel" version if your distro uses that terminology) and I included it precompiled for Windows. It's a bit difficult for Linux because of dependencies and admittedly I have no idea how it is handled on NI RT Linux - I've never developed for such a system myself.
You can always try compiling it from source if there are no binaries available: https://www.hdfgroup.org/downloads/hdf5/
Make sure to get 1.10.X as I'm sure there will be compatibility issues with 1.12.X.
You might be able to "cross compile" it on a host Linux PC and copy that across the the RT Linux target - I believe some users have had some success doing that in the past.
Cheers,
Martijn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your reply, this has given me some more insights on how to do this. So after a rollercoaster ride of trying to build the HDF5 library and modifying the make file to build your library on Linux, I have finally made some progress, but i'm also running into a few issues.
I've added the build HDF5 library, the h5labview.so file and the makefile to this post, so if you want to use them, they are probably ready for all the NI RT Linux devices that have an x64 processor
When I tried to run the test_suite.vi the application crashed hard on the RT Target. So I tried to figure out what's causing this, and because I have no feedback on the crashes, I recreated the test procedure with the "Call By reference" and found that the following VI's were causing the crashes:
- array_cluster.vi
- cluster_nested.vi
- variant_empty.vi
- variant_read.vi
- variant_write.vi
Next to the crashes we also had 3 tests that were not successfull and they reported no errors:
- array_units
- numeric_cluster
- numeric_dblarr
Do you know why any of these issues happen? or maybe something we can test to pinpoint the problem? maybe it's something I did wrong in the makefile?
Almost certainly it's due to memory alignment. There are differences "under the hood" between LabVIEW on different operating systems which matter for efficient data IO as is used in this library. To avoid such problems requires costly/slow datatype conversions getting data in/out of the library, but on the other hand it can cause a lot of crashes in getting it right.
Probably the environment requires alignment to 8-byte boundaries whereas it's being compiled for 4-byte boundaries on the host linux system. You could try overriding LVALIGNMENT to be 8. Again, since I don't have an NI RT environment to test in, this is just speculation.
Cheers,
Martijn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks again for the reply, I took us a little while to get into this, but we finally got it working. Changing the LVALIGNMENT in the h5labview.h file did the trick. After building the new .so file we got all the tests working.
I've added the so file to this post for others that run into the same problem.
Very glad to hear you were able to get it working! Thanks for providing the compiled SO, I'm sure your experience getting it to work will be very helpful for anyone else trying to get this running on NI RT.
Cheers,
Martijn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Martijn,
We are creating an application for a PXI running NI RT Linux with LV 2020 installed. I'm not really familiar with building so files for linux, but I looked up how to build, so i prepped my NI RT device with the build tools (make, gcc, etc) and copied the contents of the lib directory to the device.
I tried to build using
gcc -c -fPIC h5labview.c -o h5labview.o
but it gives me the error
So I'm guessing I have to install some sort of HDF5 library which contains this header file or am I missing something?
I also read somewhere on this forum that there should be a pre build so file, but I cannot find it.
Hello Bas,
You need to install "libhdf". Any standard distro package manager should provide it precompiled or ported (you will likely need the "devel" version if your distro uses that terminology) and I included it precompiled for Windows. It's a bit difficult for Linux because of dependencies and admittedly I have no idea how it is handled on NI RT Linux - I've never developed for such a system myself.
You can always try compiling it from source if there are no binaries available: https://www.hdfgroup.org/downloads/hdf5/
Make sure to get 1.10.X as I'm sure there will be compatibility issues with 1.12.X.
You might be able to "cross compile" it on a host Linux PC and copy that across the the RT Linux target - I believe some users have had some success doing that in the past.
Cheers,
Martijn
Thank you for your reply, this has given me some more insights on how to do this. So after a rollercoaster ride of trying to build the HDF5 library and modifying the make file to build your library on Linux, I have finally made some progress, but i'm also running into a few issues.
I've added the build HDF5 library, the h5labview.so file and the makefile to this post, so if you want to use them, they are probably ready for all the NI RT Linux devices that have an x64 processor
When I tried to run the test_suite.vi the application crashed hard on the RT Target. So I tried to figure out what's causing this, and because I have no feedback on the crashes, I recreated the test procedure with the "Call By reference" and found that the following VI's were causing the crashes:
- array_cluster.vi
- cluster_nested.vi
- variant_empty.vi
- variant_read.vi
- variant_write.vi
Next to the crashes we also had 3 tests that were not successfull and they reported no errors:
- array_units
- numeric_cluster
- numeric_dblarr
Do you know why any of these issues happen? or maybe something we can test to pinpoint the problem? maybe it's something I did wrong in the makefile?
Last edit: Bas 2021-08-09
Almost certainly it's due to memory alignment. There are differences "under the hood" between LabVIEW on different operating systems which matter for efficient data IO as is used in this library. To avoid such problems requires costly/slow datatype conversions getting data in/out of the library, but on the other hand it can cause a lot of crashes in getting it right.
The relevant documentation is here: https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/how_labview_stores_data_in_memory/, particularly the part about clusters (although it applies to more than just clusters)
Probably the environment requires alignment to 8-byte boundaries whereas it's being compiled for 4-byte boundaries on the host linux system. You could try overriding LVALIGNMENT to be 8. Again, since I don't have an NI RT environment to test in, this is just speculation.
Cheers,
Martijn
Thanks again for the reply, I took us a little while to get into this, but we finally got it working. Changing the LVALIGNMENT in the h5labview.h file did the trick. After building the new .so file we got all the tests working.
I've added the so file to this post for others that run into the same problem.
Very glad to hear you were able to get it working! Thanks for providing the compiled SO, I'm sure your experience getting it to work will be very helpful for anyone else trying to get this running on NI RT.
Cheers,
Martijn