opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
792 stars 317 forks source link

Compilation fails: error: static assertion failed due to requirement 'formattable': Cannot format an argument #3519

Open yurivict opened 1 year ago

yurivict commented 1 year ago
In file included from /usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/RegisterTypes_osimCommon.cpp:25:
In file included from /usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/Object.h:39:
In file included from /usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/PropertySet.h:35:
In file included from /usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/ArrayPtrs.h:33:
In file included from /usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/Exception.h:33:
In file included from /usr/local/include/spdlog/common.h:50:
In file included from /usr/local/include/spdlog/fmt/fmt.h:31:
/usr/local/include/fmt/core.h:1756:3: error: static assertion failed due to requirement 'formattable': Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt
  static_assert(
  ^
/usr/local/include/fmt/core.h:1777:10: note: in instantiation of function template specialization 'fmt::detail::make_value<fmt::basic_format_context<fmt::appender, char>, const SimTK::Vec<3, double, 1> &>' requested here
  return make_value<Context>(val);
         ^
/usr/local/include/fmt/core.h:1899:23: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::basic_format_context<fmt::appender, char>, fmt::detail::type::custom_type, const SimTK::Vec<3, double, 1> &, 0>' requested here
        data_{detail::make_arg<
                      ^
/usr/local/include/fmt/core.h:1918:10: note: in instantiation of function template specialization 'fmt::format_arg_store<fmt::basic_format_context<fmt::appender, char>, SimTK::Vec<3, double, 1>, int, unsigned int>::format_arg_store<const SimTK::Vec<3, double, 1> &, const int &, const unsigned int &>' requested here
  return {FMT_FORWARD(args)...};
         ^
/usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/Reporter.h:334:25: note: in instantiation of function template specialization 'fmt::format<const SimTK::Vec<3, double, 1> &, const int &, const unsigned int &>' requested here
            msg += fmt::format("{:>{}.{}g}| ", value, _width, nSigFigs);
                        ^
/usr/ports/science/opensim-core/work/opensim-core-4.4/OpenSim/Common/RegisterTypes_osimCommon.cpp:102:27: note: in instantiation of member function 'OpenSim::ConsoleReporter_<SimTK::Vec<3, double, 1>>::implementReport' requested here
    Object::registerType( ConsoleReporterVec3() );
                          ^
1 error generated.

Version: 4.4 spdlog-1.12.0 libfmt-9.1.0 clang-15 FreeBSD 13.2

yurivict commented 7 months ago

@nickbianco

Hi Nick,

Maybe you would know why isn't ConsoleReporterVec3 formattable, and causes the error?

The 4.4 and 4.5 releases both suffer from this problem, and we can't build OpenSim-core on FreeBSD.

Thank you, Yuri

nickbianco commented 7 months ago

HI @yurivict, it looks like you might be building OpenSim with a version of spdlog from your /usr/local/include folder, which might be a different version than the version build with the OpenSim dependencies.

yurivict commented 7 months ago

Hi @nickbianco ,

OpenSim's configure looks for spdlog:

-- Found Git: /usr/local/bin/git (found version "2.43.0") 
CMake Error at CMakeLists.txt:747 (find_package):
  Could not find a package configuration file provided by "spdlog" with any
  of the following names:

    spdlogConfig.cmake
    spdlog-config.cmake

  Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
  "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
nickbianco commented 7 months ago

@yurivict, yes, but you need to build the OpenSim dependencies first. You can see the version of spdlog that we build in the CMakeLists file for the dependencies build project.

Please try that and see if you can create a successful build.

yurivict commented 7 months ago

@nickbianco How to provide to the build the tarball for the specific required version of spdlog, so that it will be rebuilt and used? It looks like by default it just uses find_package to find the pre-installed package, which happens to be of an unsupported version.

nickbianco commented 6 months ago

If you build the dependencies CMake project, the dependencies will be installed in a folder (i.e., opensim_dependencies_install) which the main OpenSim CMake project will search when building the main libraries.

Please refer to the following build scripts for guidance: https://github.com/opensim-org/opensim-core/tree/main/scripts/build.