Giter VIP home page Giter VIP logo

matio-cpp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matio-cpp's Issues

[Not an issue] AUR packages

I have packaged matio-cpp into the AUR for archlinux users.
It can be found as git version libmatio-cpp-git or release libmatio-cpp.

Both can be built using an AUR helper or by doing:

git clone https://aur.archlinux.org/libmatio-cpp[-git].git
cd libmatio-cpp[-git]
makepkg -si

It may help Archlinux users to install, manage and use matioCpp.

If you want more information, please notify me.

Problem with linking library

Hi,

For the last days I have been trying to link matio-cpp to my project, but without success. I am rather new to cmake, but it seems that I have successfully built and installed the binaries.
I included the library in my project with find_package(matioCpp REQUIRED) (which seems to find the package properly) and linking the libraries with target_link_libraries(my_project PRIVATE matioCpp::matioCpp).

However, when trying to create a MAT-file, I get an undefined reference error for matioCpp::File::Create(...) and matioCpp::File::~File(), which indicates that only the headers are imported, but not the implementations.

Any help would be greatly appreciated! I realize this is not really a problem that is specific to matio-cpp, but it would be awesome if someone could help me out a bit.

Generated matfile are not hdf5 compatible

I would like to open a mat file generated by matioCpp in python using h5py (see here) this should be actually possible since all the mat files generated with Matlab R2006b or later are hdf5 datasets.

However when I try to inspect the file with h5debug I got

h5debug test.mat
cannot open file

If I open the file in Matlab and I save it with the following command

save('test_from_matlab.mat', '-v7.3')

I can easily inspect the content of the file with h5debug

h5debug test_from_matlab.mat
Reading signature at address 0 (rel)
File Super Block...
File name (as opened):                             test_from_matlab.mat
File name (after resolving symlinks):              test_from_matlab.mat
File access flags                                  0x00000000
File open reference count:                         1
Address of super block:                            512 (abs)
Size of userblock:                                 512 bytes
Superblock version number:                         0
Free list version number:                          0
Root group symbol table entry version number:      0
Shared header version number:                      0
Size of file offsets (haddr_t type):               8 bytes
Size of file lengths (hsize_t type):               8 bytes
Symbol table leaf node 1/2 rank:                   4
Symbol table internal node 1/2 rank:               16
Indexed storage internal node 1/2 rank:            32
File status flags:                                 0x00
Superblock extension address:                      UNDEF (rel)
Shared object header message table address:        UNDEF (rel)
Shared object header message version number:       0
Number of shared object header message indexes:    0
Address of driver information block:               UNDEF (rel)
Root group symbol table entry:                     
   Name offset into private heap:                  0
   Object header address:                          96
   Cache info type:                                Symbol Table
   Cached entry information:                      
      B-tree address:                              136
      Heap address:                                680

This is the c++ application I wrote for the test

#include <matioCpp/matioCpp.h>
#include <vector>
#include <string>

int main()
{
    matioCpp::File file = matioCpp::File::Create("test.mat");

    std::vector<double> in = {2.0,4.0,6.0,8.0};
    matioCpp::Vector<double> out("test_vector");
    out = in;
    file.write(out);

    matioCpp::String testString("string_name");
    testString = "string content";
    file.write(testString);

    return 0;
}

The .mat file version saved by matioCpp is actually pretty old (v5.0)

type('test.mat')

MATLAB 5.0 MAT-file, created by matioCpp v0.1.1 via libmatio v1.5.17 on Wed Dec 15 16:13:35 2021.�                          ��IM����`���������������������������������������test_vector�����	��� ����������@�������@�������@������ @����P���������������������������������������string_name�������������string content��

Is there a way to change the version of the mat file stored by matioCpp?

*.tpp files throw syntax error

Hello there
What I got when I tried to load this library into vcpkg:

Severity Code Description Project File String Suppression Status
Error C2760 syntax error: expected token ';' not 'id' wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 70
Severity Code Description Project File String Suppression Status
Error C2760 syntax error: expected token ';' not 'identifier' wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 93
Error C2760 syntax error: expected token ';' not 'id' wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 159
Error C2760 syntax error: expected token ';' not 'identifier' wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 248
Error C2589 (: invalid token to the right of "::" wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\vector.tpp 265
Error C2589 (: invalid token to the right of "::" wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\vector.tpp 274
Error C7510 "index_type": when using dependent name type, you must prefix "type name" wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 70
Error C7510 "index_type": When using dependent name type, you must prefix "type name" wtf c:\temp\vcpkg\installed\x64-windows\include\matiocpp\impl\multidimensionalarray.tpp 248

I tried compiling the dll and lib via just cmake on VS2017 and got the same results...

What am I doing wrong?)

Add path/name of the file that matio-cpp failed to create

Often the failure of the creation of the file is related to the specification to a folder that does not exist in your filesystem or on which you don't have the rights of write.

At this moment matio-cpp print this error in case of failure:

[ERROR][matioCpp::File::Create] Failed to open the file.
[ERROR][matioCpp::File::write] The file is not open.

It would be nice if it specify also the name/path of the file it tried to save like:

[ERROR][matioCpp::File::Create] Failed to open the file /home/icub/foo/foo.mat.
[ERROR][matioCpp::File::write] The file is not open /home/icub/foo/foo.mat.

Cannot read mat files saved from Python with `7.3` format

I saved a .mat file from Python using hdf5storage.savemat with the default format 7.3.
In my C++ application, I opened the file, read the structure, and checked the number of fields.

matioCpp::File input(file);
matioCpp::Struct outStruct = input.read("robot").asStruct();
std::vector<std::string> listVar = input.variableNames();
std::cout << "Num variables: " << listVar.size());

However, the output was 0. I verified the content in Matlab, and it was correct.

In summary, the file opening works fine, but the variable returned by the read method is empty

matioCpp::Variable read(const std::string& name) const;

I solved the problem by saving the .mat file with format 5 instead of 7.3.

cc @S-Dafarra

Missing deduction guides for Span object

Accordingly to the std documentation the following code should work

std::vector<int32_t> v{2};
matioCpp::Span s{v};

However when I try to compile the code I got

home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: error: class template argument deduction failed:
   44 |         matioCpp::Span s{v};
      |                           ^
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: error: no matching function for call to ‘Span(std::vector<int>&)’
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:558:24: note: candidate: ‘template<class ElementType, long int Extent> Span(matioCpp::Span<ElementType, Extent>::KnownNotNull, matioCpp::Span<ElementType, Extent>::index_type)-> matioCpp::Span<ElementType, Extent>’
  558 |     MATIOCPP_CONSTEXPR Span(KnownNotNull ptr, index_type count) : storage_(ptr, count) {}
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:558:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   candidate expects 2 arguments, 1 provided
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:424:24: note: candidate: ‘template<class ElementType, long int Extent, class OtherElementType, long int OtherExtent, class> Span(const matioCpp::Span<OtherElementType, OtherExtent>&)-> matioCpp::Span<ElementType, Extent>’
  424 |     MATIOCPP_CONSTEXPR Span(const Span<OtherElementType, OtherExtent>& other)
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:424:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   ‘std::vector<int>’ is not derived from ‘const matioCpp::Span<OtherElementType, OtherExtent>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:416:24: note: candidate: ‘template<class ElementType, long int Extent> Span(const matioCpp::Span<ElementType, Extent>&)-> matioCpp::Span<ElementType, Extent>’
  416 |     MATIOCPP_CONSTEXPR Span(const Span& other) noexcept = default;
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:416:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   ‘std::vector<int>’ is not derived from ‘const matioCpp::Span<ElementType, Extent>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:411:24: note: candidate: ‘template<class ElementType, long int Extent, class Container, class, class> Span(const Container&)-> matioCpp::Span<ElementType, Extent>’
  411 |     MATIOCPP_CONSTEXPR Span(const Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:411:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   couldn’t deduce template parameter ‘ElementType’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:402:24: note: candidate: ‘template<class ElementType, long int Extent, class Container, class, class> Span(Container&)-> matioCpp::Span<ElementType, Extent>’
  402 |     MATIOCPP_CONSTEXPR Span(Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:402:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   couldn’t deduce template parameter ‘ElementType’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:389:24: note: candidate: ‘template<class ElementType, long int Extent, long unsigned int N> Span(const std::array<typename std::remove_const<_Tp>::type, N>&)-> matioCpp::Span<ElementType, Extent>’
  389 |     MATIOCPP_CONSTEXPR Span(const std::array<std::remove_const_t<element_type>, N>& arr) noexcept
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:389:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   ‘std::vector<int>’ is not derived from ‘const std::array<typename std::remove_const<_Tp>::type, N>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:383:24: note: candidate: ‘template<class ElementType, long int Extent, long unsigned int N, class ArrayElementType> Span(std::array<ArrayElementType, N>&)-> matioCpp::Span<ElementType, Extent>’
  383 |     MATIOCPP_CONSTEXPR Span(std::array<ArrayElementType, N>& arr) noexcept
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:383:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   ‘std::vector<int>’ is not derived from ‘std::array<ArrayElementType, N>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:377:24: note: candidate: ‘template<class ElementType, long int Extent, long unsigned int N> Span(ElementType (&)[N])-> matioCpp::Span<ElementType, Extent>’
  377 |     MATIOCPP_CONSTEXPR Span(element_type (&arr)[N]) noexcept
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:377:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   mismatched types ‘ElementType [N]’ and ‘std::vector<int>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:371:24: note: candidate: ‘template<class ElementType, long int Extent> Span(matioCpp::Span<ElementType, Extent>::pointer, matioCpp::Span<ElementType, Extent>::pointer)-> matioCpp::Span<ElementType, Extent>’
  371 |     MATIOCPP_CONSTEXPR Span(pointer firstElem, pointer lastElem)
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:371:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   mismatched types ‘matioCpp::Span<ElementType, Extent>::element_type*’ and ‘std::vector<int>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:369:24: note: candidate: ‘template<class ElementType, long int Extent> Span(matioCpp::Span<ElementType, Extent>::pointer, matioCpp::Span<ElementType, Extent>::index_type)-> matioCpp::Span<ElementType, Extent>’
  369 |     MATIOCPP_CONSTEXPR Span(pointer ptr, index_type count) : storage_(ptr, count) {}
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:369:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   mismatched types ‘matioCpp::Span<ElementType, Extent>::element_type*’ and ‘std::vector<int>’
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:364:24: note: candidate: ‘template<class ElementType, long int Extent, bool Dependent, class> Span()-> matioCpp::Span<ElementType, Extent>’
  364 |     MATIOCPP_CONSTEXPR Span() noexcept : storage_(nullptr, details::extent_type<0>())
      |                        ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:364:24: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   candidate expects 0 arguments, 1 provided
   44 |         matioCpp::Span s{v};
      |                           ^
In file included from /home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:30,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
                 from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/ForwardDeclarations.h:176:7: note: candidate: ‘template<class ElementType, long int Extent> Span(matioCpp::Span<ElementType, Extent>)-> matioCpp::Span<ElementType, Extent>’
  176 | class Span;
      |       ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/ForwardDeclarations.h:176:7: note:   template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note:   ‘std::vector<int>’ is not derived from ‘matioCpp::Span<ElementType, Extent>’
   44 |         matioCpp::Span s{v};

In this case the used deduction guides used should be:

template<class R>
span(R&&) -> span<std::remove_reference_t<std::ranges::range_reference_t<R>>>;

Do a release

I just realized that we do not have a release for this repo, and robotology/robotology-superbuild#596 is not complaining as no release is available at all. Can we add one? Also a minimal 0.0.1 or 0.1.0 release would be great.

CI Failure April 2024

Message failure:

CMake Warning at /home/runner/work/matio-cpp/matio-cpp/install/lib/cmake/matioCpp/matioCppConfig.cmake:24 (find_package):
  By not providing "FindMATIO.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "MATIO", but
  CMake did not find one.

  Could not find a package configuration file provided by "MATIO" with any of
  the following names:

    MATIOConfig.cmake
    matio-config.cmake

  Add the installation prefix of "MATIO" to CMAKE_PREFIX_PATH or set
  "MATIO_DIR" to a directory containing one of the above files.  If "MATIO"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)


-- Configuring done (0.2s)
CMake Error at /home/runner/work/matio-cpp/matio-cpp/install/lib/cmake/matioCpp/matioCppTargets.cmake:61 (set_target_properties):
-- Generating done (0.0s)
  The link interface of target "matioCpp::matioCpp" contains:

    MATIO::MATIO

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /home/runner/work/matio-cpp/matio-cpp/install/lib/cmake/matioCpp/matioCppConfig.cmake:33 (include)
  CMakeLists.txt:4 (find_package)


CMake Generate step failed.  Build files cannot be regenerated correctly.

see #77 .

Originally found by @Nicogene .

Investigate the possibility of automatically converting a struct into a matioCpp struct using reflection

Related links:

https://stackoverflow.com/questions/63467178/modern-way-to-access-struct-fields-by-name-in-c

In particular, I found pretty interesting https://github.com/garbageslam/visit_struct

The main drawback is that the struct needs to be modified, specifying which entry can be accessed. On the other hand, this might be useful since some types cannot be automatically converted into matioCpp variables. In addition, the options that do not need to modify the struct, usually cannot get the names of the fields. See https://bytemaster.github.io/boost_reflect/ and https://github.com/apolukhin/magic_get

Thread Safety

Hello there,

is it possible to read multiple large structs (1-3 GB) from a MAT-file concurrently?
I found nothing on this github page regarding thread safety.

If it is not supported out of the box then how would one go about it?

Memory problem

Hi,

When trying to run the example code of creating a file and writing some values to it, my program crashes with the following error:
image

When looking at the debug information, the error originates from the following line of code from the example:
testString = "string content";
Digging in further, the program crashes at the return statement of the matioCpp::Vector<T> &matioCpp::Vector<T>::operator=(const string_input_type &other) function that is called (line 213 in Vector.tpp).
When diving down deeper, functions are called from the std::string library and finally crashing at a call of std::allocator<char>::deallocate.

I am compiling this program using MSVC on Windows.
The code I am trying to get working:

    matioCpp::File file = matioCpp::File::Create("created_file.mat");

    matioCpp::String testString("string_name");
    testString = "string content";
    file.write(testString);

Test #11 failing

Hi again,

After removing all installed packages and starting fresh, I run into a new issue.
I installed Matio with all its dependencies using vcpkg (as a Git submodule) for x64-windows in my project. Afterwards I installed MatioCpp using cmake for MSVC, pointing it to the just intalled Matio files.

My project (a Qt6 application) is building fine and I can include the MatioCpp library without issues. However when I try to read a .mat file, it does not open the file. I am completely sure the filename and path is correct. I have tried relative and absolute paths, but it does not open (checking with the File.isOpen() method). I also tried to open the file readOnly, but no success.

To understand why, I rebuilt MatioCpp with tests and ran it using ctest -C Release in the build directory, yielding results below. It seems there is a problem in the fileUnitTests (test 11), which could perhaps explain my original problem.

How to go about solving this?
Cheers, Daan

Start testing: Apr 26 22:59 Central Europe Summer Time
----------------------------------------------------------
1/15 Testing: test_visit_struct
1/15 Test: test_visit_struct
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/test_visit_struct.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/_deps/visit_struct-build
"test_visit_struct" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
1.0.0
C:\Users\Daan\source\repos\H2Analyst\H2Analyst\extern\matio-cpp-0.2.2\build\_deps\visit_struct-src\test_visit_struct.cpp
{
  a: 5
  b: 7.5
  c: asdf
}
{
  a: 0
  b: 0
  c: jkl
}
{
  d: -1
  i: 5
  b: 0
}
{
  d: 0.75
  i: -14
  b: 1
}
<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"test_visit_struct" end time: Apr 26 22:59 Central Europe Summer Time
"test_visit_struct" time elapsed: 00:00:00
----------------------------------------------------------

2/15 Testing: test_fully_visitable
2/15 Test: test_fully_visitable
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/test_fully_visitable.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/_deps/visit_struct-build
"test_fully_visitable" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
<end of output>
Test time =   0.01 sec
----------------------------------------------------------
Test Passed.
"test_fully_visitable" end time: Apr 26 22:59 Central Europe Summer Time
"test_fully_visitable" time elapsed: 00:00:00
----------------------------------------------------------

3/15 Testing: test_visit_struct_intrusive
3/15 Test: test_visit_struct_intrusive
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/test_visit_struct_intrusive.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/_deps/visit_struct-build
"test_visit_struct_intrusive" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
C:\Users\Daan\source\repos\H2Analyst\H2Analyst\extern\matio-cpp-0.2.2\build\_deps\visit_struct-src\test_visit_struct_intrusive.cpp
{
  b: 1
  i: 5
  f: 7.5
}
{
  b: 1
  i: 0
  f: 0
}
<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"test_visit_struct_intrusive" end time: Apr 26 22:59 Central Europe Summer Time
"test_visit_struct_intrusive" time elapsed: 00:00:00
----------------------------------------------------------

4/15 Testing: MatvarHandlerUnitTests
4/15 Test: MatvarHandlerUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/MatvarHandlerUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"MatvarHandlerUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 3047830428
[ERROR][matioCpp::WeakMatvar::importMatvar] Cannot import inputPtr. A WeakMatvar cannot modify the matvar pointer.
[ERROR][matioCpp::WeakMatvar::duplicateFromMatio] Cannot duplicate from inputPtr. A WeakMatvar cannot modify the matvar pointer.
===============================================================================
All tests passed (65 assertions in 10 test cases)

<end of output>
Test time =   0.05 sec
----------------------------------------------------------
Test Passed.
"MatvarHandlerUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"MatvarHandlerUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

5/15 Testing: SpanUnitTests
5/15 Test: SpanUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/SpanUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"SpanUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 1929862173
===============================================================================
All tests passed (391 assertions in 30 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"SpanUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"SpanUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

6/15 Testing: VariableUnitTests
6/15 Test: VariableUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/VariableUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"VariableUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 773870483
===============================================================================
All tests passed (142 assertions in 6 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"VariableUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"VariableUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

7/15 Testing: VectorUnitTests
7/15 Test: VectorUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/VectorUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"VectorUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 2279363864
===============================================================================
All tests passed (282 assertions in 6 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"VectorUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"VectorUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

8/15 Testing: MultiDimensionalArrayUnitTests
8/15 Test: MultiDimensionalArrayUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/MultiDimensionalArrayUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"MultiDimensionalArrayUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 2520532841
===============================================================================
All tests passed (297 assertions in 6 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"MultiDimensionalArrayUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"MultiDimensionalArrayUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

9/15 Testing: ElementUnitTests
9/15 Test: ElementUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/ElementUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"ElementUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 3934746561
===============================================================================
All tests passed (94 assertions in 6 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"ElementUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"ElementUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

10/15 Testing: CellArrayUnitTests
10/15 Test: CellArrayUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/CellArrayUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"CellArrayUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 434559880
===============================================================================
All tests passed (399 assertions in 4 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"CellArrayUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"CellArrayUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

11/15 Testing: FileUnitTests
11/15 Test: FileUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/FileUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"FileUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 3337339379
[ERROR][matioCpp::File::Create] The path /shouldFail does not exists (input file name /shouldFail/test.mat).
[ERROR][matioCpp::File::write] The variable name can contain only alphanumeric characters or underscores (Variable name = "Should Fail").
[ERROR][matioCpp::File::Create] Failed to open the file named test73.mat.
[ERROR][matioCpp::File::write] The file is not open.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FileUnitTests.exe is a Catch2 v3.3.2 host application.
Run with -? for options

-------------------------------------------------------------------------------
Write version 7.3
-------------------------------------------------------------------------------
C:\Users\Daan\source\repos\H2Analyst\H2Analyst\extern\matio-cpp-0.2.2\test\FileUnitTest.cpp(372)
...............................................................................

C:\Users\Daan\source\repos\H2Analyst\H2Analyst\extern\matio-cpp-0.2.2\test\FileUnitTest.cpp(379): FAILED:
  REQUIRE( file.write(doubleVar) )
with expansion:
  false

===============================================================================
test cases:  11 |  10 passed | 1 failed
assertions: 240 | 239 passed | 1 failed

<end of output>
Test time =   0.03 sec
----------------------------------------------------------
Test Failed.
"FileUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"FileUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

12/15 Testing: StructUnitTests
12/15 Test: StructUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/StructUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"StructUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 4075732859
===============================================================================
All tests passed (252 assertions in 4 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"StructUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"StructUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

13/15 Testing: StructArrayUnitTests
13/15 Test: StructArrayUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/StructArrayUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"StructArrayUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 1091078944
===============================================================================
All tests passed (436 assertions in 3 test cases)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"StructArrayUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"StructArrayUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

14/15 Testing: StructArrayElementUnitTests
14/15 Test: StructArrayElementUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/StructArrayElementUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"StructArrayElementUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 3204293313
===============================================================================
All tests passed (62 assertions in 1 test case)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"StructArrayElementUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"StructArrayElementUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

15/15 Testing: ExogenousConversionsUnitTests
15/15 Test: ExogenousConversionsUnitTests
Command: "C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/bin/Release/ExogenousConversionsUnitTests.exe"
Directory: C:/Users/Daan/source/repos/H2Analyst/H2Analyst/extern/matio-cpp-0.2.2/build/test
"ExogenousConversionsUnitTests" start time: Apr 26 22:59 Central Europe Summer Time
Output:
----------------------------------------------------------
Randomness seeded to: 1605626396
===============================================================================
All tests passed (97 assertions in 1 test case)

<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Passed.
"ExogenousConversionsUnitTests" end time: Apr 26 22:59 Central Europe Summer Time
"ExogenousConversionsUnitTests" time elapsed: 00:00:00
----------------------------------------------------------

End testing: Apr 26 22:59 Central Europe Summer Time

Failed FileUnitTests

Problem

After a clean build, 10 of the tests pass, and the 8th (FileUnitTests) constantly fails.

Environment

  • Archlinux Rolling
  • kernel 5.10.10
  • MatIO 1.5.19
  • CMake 3.19.3
  • GNU Make 4.3
  • GCC 10.2.0
  • Catch2 2.13.3

Steps

It has been tested to remove code blocks between []. Code between <|> have all been tested independently.

git clone https://github.com/dic-iit/matio-cpp.git && cd matio-cpp
cmake -B build . -DBUILD_TESTING=ON [-DCMAKE_BUILD_TYPE=<None|Release|Debug>]
cd build
make [-j]
ctest -V

Results

Every tests pass except the 8th which fail with:

ctest.log

It seems only related to strings so it may not impact the remains of the library.
Do you know from where it could originate? Can it be a problem from Matio (since it seems problems with strings exist)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.