2b-t / myactuator_rmd

C++ and Python SDK for controlling actuators of the MyActuator RMD-X series, written in C++ with Python bindings
MIT License
15 stars 12 forks source link

Error installing python package or building C++ library: ‘struct can_frame’ has no member named ‘len’ #8

Closed TheIndoorDad closed 3 months ago

TheIndoorDad commented 3 months ago

Hello,

I'm trying to install as a Python package, but I'm getting an error I don't know how to resolve when I do pip3 install .. I think the key error is /home/user/ContinuO_Python/myactuator_rmd/src/can/node.cpp:150:13: error: ‘struct can_frame’ has no member named ‘len’, but I'm not certain.

I'm on Ubuntu 20.04, and I should have all dependencies installed (I had to compile cmake >= 3.20 from source and install as a DEB package). One caveat is that I'm on a lowlatency kernel and when I attempt to execute sudo apt-get install linux-modules-extra-$(uname -r) I get E: Package 'linux-modules-extra-5.15.0-110-lowlatency' has no installation candidate.

My output:

Processing /home/user/ContinuO_Python/myactuator_rmd
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: myactuator_rmd_py
  Building wheel for myactuator_rmd_py (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for myactuator_rmd_py (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [110 lines of output]
      running bdist_wheel
      running build
      running build_ext
      -- The C compiler identification is GNU 9.4.0
      -- The CXX compiler identification is GNU 9.4.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found Python: /home/user/ContinuO_Python/.venv/bin/python3 (found version "3.8.10") found components: Interpreter Development Development.Module Development.Embed
      CMake Deprecation Warning at /usr/lib/cmake/pybind11/pybind11Tools.cmake:8 (cmake_minimum_required):
        Compatibility with CMake < 3.5 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
      Call Stack (most recent call first):
        /usr/lib/cmake/pybind11/pybind11Config.cmake:100 (include)
        CMakeLists.txt:56 (find_package)

      CMake Warning (dev) at /usr/lib/cmake/pybind11/FindPythonLibsNew.cmake:60 (find_package):
        Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
        are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
        the cmake_policy command to set the policy and suppress this warning.

      Call Stack (most recent call first):
        /usr/lib/cmake/pybind11/pybind11Tools.cmake:16 (find_package)
        /usr/lib/cmake/pybind11/pybind11Config.cmake:100 (include)
        CMakeLists.txt:56 (find_package)
      This warning is for project developers.  Use -Wno-dev to suppress it.

      -- Found PythonInterp: /home/user/ContinuO_Python/.venv/bin/python (found version "3.8.10")
      -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
      -- Performing Test HAS_FLTO
      -- Performing Test HAS_FLTO - Success
      -- LTO enabled
      -- Configuring done (0.5s)
      -- Generating done (0.0s)
      -- Build files have been written to: /home/user/ContinuO_Python/myactuator_rmd/build/temp.linux-x86_64-cpython-38/myactuator_rmd_py
      [ 12%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/can/node.cpp.o
      /home/user/ContinuO_Python/myactuator_rmd/src/can/node.cpp: In member function ‘void myactuator_rmd::can::Node::write(uint32_t, const std::array<unsigned char, 8>&)’:
      /home/user/ContinuO_Python/myactuator_rmd/src/can/node.cpp:150:13: error: ‘struct can_frame’ has no member named ‘len’
        150 |       frame.len = 8;
            |             ^~~
      make[2]: *** [CMakeFiles/myactuator_rmd.dir/build.make:76: CMakeFiles/myactuator_rmd.dir/src/can/node.cpp.o] Error 1
      make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/myactuator_rmd.dir/all] Error 2
      make: *** [Makefile:136: all] Error 2
      Traceback (most recent call last):
        File "/home/user/ContinuO_Python/.venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/user/ContinuO_Python/.venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/user/ContinuO_Python/.venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 415, in build_wheel
          return self._build_with_temp_dir(
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 56, in <module>
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 976, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/command/bdist_wheel.py", line 373, in run
          self.run_command("build")
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 976, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 976, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 93, in run
          _build_ext.run(self)
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 359, in run
          self.build_extensions()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 479, in build_extensions
          self._build_extensions_serial()
        File "/tmp/pip-build-env-fib9wcpr/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 505, in _build_extensions_serial
          self.build_extension(ext)
        File "<string>", line 52, in build_extension
        File "/usr/lib/python3.8/subprocess.py", line 516, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['cmake', '--build', '.']' returned non-zero exit status 2.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for myactuator_rmd_py
Failed to build myactuator_rmd_py
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (myactuator_rmd_py)

If I instead attempt to build as a C++ library with Python bindings on, I get a similar error after make:

(.venv) user@ContinuO-Laptop-Linux:~/ContinuO_Python/myactuator_rmd/build$ make -j $(nproc)
[ 12%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/can/node.cpp.o
[ 25%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/can/utilities.cpp.o
[ 37%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/protocol/requests.cpp.o
[ 50%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/protocol/responses.cpp.o
[ 62%] Building CXX object CMakeFiles/myactuator_rmd.dir/src/actuator_interface.cpp.o
/home/user/ContinuO_Python/myactuator_rmd/src/can/utilities.cpp: In function ‘std::ostream& operator<<(std::ostream&, const can_frame&)’:
/home/user/ContinuO_Python/myactuator_rmd/src/can/utilities.cpp:11:29: error: ‘const struct can_frame’ has no member named ‘len’
   11 |   for (int i = 0; i < frame.len; i++) {
      |                             ^~~
make[2]: *** [CMakeFiles/myactuator_rmd.dir/build.make:90: CMakeFiles/myactuator_rmd.dir/src/can/utilities.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/user/ContinuO_Python/myactuator_rmd/src/can/node.cpp: In member function ‘void myactuator_rmd::can::Node::write(uint32_t, const std::array<unsigned char, 8>&)’:
/home/user/ContinuO_Python/myactuator_rmd/src/can/node.cpp:150:13: error: ‘struct can_frame’ has no member named ‘len’
  150 |       frame.len = 8;
      |             ^~~
make[2]: *** [CMakeFiles/myactuator_rmd.dir/build.make:76: CMakeFiles/myactuator_rmd.dir/src/can/node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/myactuator_rmd.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Thank you for your assistance, I'm a novice.

TheIndoorDad commented 3 months ago

Like a dummy I neglected to check closed issues before posting, and now see there is one that may be relevant. Looking at that now and I will report back. Sorry for possible duplication.

2b-t commented 3 months ago

Yes, this sounds like https://github.com/2b-t/myactuator_rmd/issues/5. Let me know if that works for you!

TheIndoorDad commented 3 months ago

Yes, after reviewing #5 I changed both line 150 of /src/can/node.cpp and line 11 of /src/can/utilities.cpp to use can_dlc instead of len and that worked.

For posterity my can_frame struct in linux/can.h does include both len and can_dlc, and only node.cpp seemed to raise the error so may be that I only had to change that one.

Thanks again!

2b-t commented 3 months ago

Hmmm, can_dlc is the legacy name that len had prior to 2020. I had a quick glance at can-utils when I was made aware of this issue but could not find an easy solution for it. As in newer versions len should be used instead and Ubuntu 20.04 is reaching its end of life next year, I will just leave it the way it is and hope people running into the very same issue will find this Github issue.